27 lines
578 B
C#
27 lines
578 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
//[RequireComponent(typeof(Rigidbody))] ;
|
|
|
|
public class Jumping : MonoBehaviour
|
|
{
|
|
[SerializeField] private float jumpForce;
|
|
//Start is called before the first frame update
|
|
private Rigidbody _rb;
|
|
|
|
private void Awake()
|
|
{
|
|
_rb = GetComponent<Rigidbody>();
|
|
}
|
|
|
|
//Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Space))
|
|
{
|
|
_rb.AddForce(new Vector3(0, jumpForce, 0), ForceMode.Impulse);
|
|
}
|
|
}
|
|
}
|