Jumping OnTriggerEnter function

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 :frowning:

    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]

It jumped once for me too, then i realized i had not tagged the ground properly, make sure the tag name matches and teh ground is set as ‘is trigger’, (u will need a 2nd clone ground set as ‘is trigger’ for obvious reasons (character will fall straight through it))

You should use a CharacterController and use:

if(CharacterController.isGrounded)
   Debug.Log("Is grounded");
//or if it isn't grounded.
if(!CharactrController.isGrounded)
   Debug.Log("Isn't grounded");

Instead of using a variable.

hope that helped a bit!

-bert