- Home /
How to clear all forces but not the gravity force?
Hello!
I have a object that falls and moves forward. When I clear the forces using rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero;
it drops down very slowly even when I use a large mass. How can I clear every force except the gravity?
Answer by KoenigX3 · Jan 15, 2017 at 05:36 PM
If there are no other forces which would make the body fall down, you could use
rb.velocity = new Vector3(0, rb.velocity.y, 0);
If there are other forces, that could make the body fall down, and you want to clear those as well, you should track them, and apply the clearing later on, but this is a bit complicated.
Also, using AddForce() without specifying a ForceMode can lead to continuous velocity-increment through multiple frames, in that case you should consider using ForceMode.Impulse or ForceMode.VelocityChange.
Your answer
Follow this Question
Related Questions
Realistic/No gravity spaceship movement? 1 Answer
Movement problem? 0 Answers
adding force to an instantiated gameobject in required direction 0 Answers
Problems making a glider 3 Answers