- Home /
How can I calculate the force required to contradict gravity?2d
Lets say I have an object with "RigidBody2". I want to apply force to it's y axis to contradict the gravity's force. so that the object will hover in the same place.
how can I calculate the required force?
Comment
Answer by tanoshimi · Jul 05, 2015 at 09:27 PM
You don't need to. Just set Rigidbody2D.gravityScale = 0;
http://docs.unity3d.com/ScriptReference/Rigidbody2D-gravityScale.html
Answer by shaibam · Jul 06, 2015 at 01:00 PM
I found this answer : http://answers.unity3d.com/questions/140232/stopping-rigidbodies-with-opposing-forces.html
var f:Vector3 = -(rigidbody.mass * rigidbody.velocity);
rigidbody.AddForce(f, ForceMode.Impulse);
rigidbody.AddForce(-(Physics.gravity), ForceMode.Acceleration);
How can I apply the power with nicer ease?
Your answer
![](https://koobas.hobune.stream/wayback/20220611225906im_/https://answers.unity.com/themes/thub/images/avi.jpg)