Search Unity

rigidbody usegravity broken?

Discussion in 'Physics' started by frostymm, Dec 5, 2014.

  1. frostymm

    frostymm

    Joined:
    Jun 21, 2013
    Posts:
    34
    So I needed to make a jumping target box.
    I put a rigidbody on it, set usegravity to true, set the boxcollider to trigger so that it would function properly with all the code I've already got for stationary targets.
    Because I set the collider to trigger, I had to detect the ground collisions myself. So I made a script that whenever the box touched the ground, usegravity would turn off.

    My problem is that even though the rigidbody turns off, the box continues to fall.
    I've checked that my code is being run, it is. And when I select the target box in the editor I can even see the checkbox on "Use Gravity" become empty as it continues to fall. Is anybody else having this problem?
     
  2. Habitablaba

    Habitablaba

    Joined:
    Aug 5, 2013
    Posts:
    136
    Do you zero out the velocity of the object when it hits the ground?
     
  3. frostymm

    frostymm

    Joined:
    Jun 21, 2013
    Posts:
    34
    Nope, completely slipped my mind. That fixed it, thank you!