Hi I am trying to set up a plattformer where the Char always jumps when he is standing on an object tagged as ground. However I am only able to jump once after that it is not possible anymore. I think the problem ist the grounded = false line in the Update function but I can’t figure out how to get this right ![]()
var jumpHeight : int;
var grounded = true;
function Update () {
// jumping controls
if(Input.GetButtonDown("Fire1")&& (grounded == true))
{
rigidbody.velocity = Vector3(0,jumpHeight,0);
grounded = false;
}
}
// collide with box and die
function OnTriggerEnter (collisionInfo : Collider) {
if (collisionInfo.gameObject.tag == "Whole")
Destroy(gameObject);
// check if char is grounded
if (collisionInfo.gameObject.tag == "Ground")
grounded = true;
}
[Edit by Berenger : Code formatting]