Hello I am a new user to Unity and I am currently using JavaScript. Right now i have a question on how to make it that my rigid body can only jump while being grounded. Right now you can press W over and over and go flying up into the sky. I am using the code
#pragma strict
var jumpSpeed: float = 10;
function Start () {
} function Update () { if
(Input.GetKeyDown (KeyCode.W)){rigidbody2D.velocity.y = jumpSpeed;
}
}
Any help would be greatly appreciated!
The ground i am using is completely flat!