I am gonna be honest I have no idea how to make my character jump, and if i search online they either have a rigidbody or a different Character Controller that I don’t understand. So I was wondering if someone could help give me a idea on how to make my character jump?
public class Player : MonoBehaviour
{
//movement variables
private CharacterController _controller;
[SerializeField]
public float _speed = 3;
public float _gravity = 9.8f;
void Start()
{
//calling up the controller to be able to control the character
_controller = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
Movement();
}
void Movement()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
Vector3 direction = new Vector3(horizontalInput, 0, verticalInput);
Vector3 velocity = direction * _speed;
velocity.y -= _gravity;
velocity = transform.transform.TransformDirection(velocity);
_controller.Move(velocity * Time.deltaTime);
}
}
