- Home /
C# always move an object forward and still use physics
Hello, I need to have my object moving forward all the time and still use rigidbody physics. I now use an transform.translate method but it ignores colliders. I need the object to funnel thru a ring. anyone got any good methods?
Answer by robertbu · Jun 06, 2013 at 02:48 PM
With physics, once you launch an object in a particular direction, it will continue to go in that direction unless acted on by an outside force like gravity, drag, or a collision. You can continually add force in the forward direction:
rigidbody.AddForce(transform.foward * amount);
But if you turn, you will not immediately head in the new forward direction because the old velocity will need to be overcome. You can increase drag (and up amount) to cause the old velocity to decay faster and therefore the object will turn faster. For unrealistic physics, you can directly manipulate the rigidbody.velocity vector.
rigidbody.velocity = transform.forward * amount;
This will result in a constant speed and immediate turns (i.e. no drift).
Your answer
Follow this Question
Related Questions
RigidBody immediately stops after AddForce 1 Answer
Multiple Cars not working 1 Answer
How would I get collision at different speeds? 2 Answers
How to limit orientation of object/rigidbody? 0 Answers
Double reference to waypoints in FSM 0 Answers