Inup.GetButtonDown not working?

For some reason in my script my Input.GetButtonDown is not working. There are no errors
its just when i start the game and press space it just does nothing. Please help
p.s. i have a little experience with coding :).

`#pragma strict
    
    var power : float = 500.0;
    function OnCollisionEnter(theCollision : Collision) {
      if(theCollision.gameObject.name == "Floor") {
      Debug.Log("Hit the floor");
      }
     if(Input.GetButtonDown("Jump")) {
        rigidbody.AddForce(Vector3(0, 0, power));   
       }
    	
    }`

That’s because your if(Input.GetBurronDown) test is contained within OnCollisionEnter(), and so will only ever have an effect if you happen to press space in exactly the same frame as your character enters a collision…

I suggest you try moving that block of code into Update() instead, which runs every frame.

You have your Input.GetButtonDown() inside OnCollisionEnter(). This code will only work in the unlikely event that you press the key down at exactly the same frame that the collision occurs. That is Input.GetButtonDown() is only true for a single frame. Assuming you want the key to only be check if there is a collision, then change ‘Input.GetButtonDown()’ to ‘Input.GetButton()’. Note this will still only be true for a single frame (because you are using OnCollisionEnter() which is only true for a single frame).