Search Unity

Really need help

Discussion in 'Scripting' started by The-Game-Master, Oct 16, 2014.

  1. The-Game-Master

    The-Game-Master

    Joined:
    Aug 6, 2014
    Posts:
    54
    I have a car with a rigidbody attatched to it (3D). I use Rigidbody.AddForce(); to account for acceleration, but when I jump a ramp or a hill, and I'm in the air, as long as I don't let go of the accelerator I keep going forward and up. Can I make it fall back to the ground if it's not touching the ground?
     
  2. cmcpasserby

    cmcpasserby

    Joined:
    Jul 18, 2014
    Posts:
    315
    your velocity seems to be adding to the local forward which in the case of hitting a bump is pushing you upwards, really what i would do is just not add velocity while in the air since your wheels arent contacting the ground
     
  3. The-Game-Master

    The-Game-Master

    Joined:
    Aug 6, 2014
    Posts:
    54
    I assume I would just create a variable and a script to set that var to false if it leaves the ground, and true if it touches, and use that var in an if. Is that right?
     
  4. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166