I currently have
if (Input.GetButton(“Jump”))
{
rb.velocity = rb.velocity + new Vector3(0,5,0);
}
What I am trying to achieve here is a single jump that cannot be repeated until the velocity (Y) returns to 0. However X & Z could be any number. How can I go about doing this? I also tried using Input.GetButtonDown but it sometimes wouldn’t activate and you could still “double jump”.
You can do something like
if (rb.velocity.y <= 0)
But if you are trying to avoid double jumping, and only let the player jump after they have landed on the floor, you’ll want to use something like OnCollisionEnter to check to see when and if the player has landed on the ground.