Hey I am trying to write a jump script, the problem is that when I press the P key sometimes the character jumps and sometimes it doesn’t. I would appreciate any help I can get.
Here is the code:
public void Update()
{
if (Controller.isGrounded) {
if (Input.GetKeyDown (KeyCode.P)) {
vSpeed = JumpSpeed;
}
}
vSpeed -= Gravity * Time.deltaTime;
MoveDirection.y = vSpeed;
}