- Home /
Rigidbody.AddForce is in what units?
What units is Rigidbody.AddForce in?
For example, are dir.x in m/s^2:
myRigidBody.AddForce (dir.x, dir.y, 0, ForceMode.Acceleration);
Answer by SteveFSP · May 26, 2010 at 01:58 PM
Yes, the unit of distance in Unity is meters per default. So acceleration will be in meters per second squared. Force in newtons. Velocity in meters per second.
Notice that the only constant in the system which dictates this is the default gravity - which you can change in the player settings. By doing so, you can make the units whatever you want - they are all just relative.
In the Unity editor: Edit > Project Settings > Physics > Gravity
So if I want to be precise, the values I choose for AddForce () should be in newtons?
If you need things to behave in a physically accurate way based on mass, using newtons (Force$$anonymous$$ode.Force) will do it. But that will add complexity. Applying an acceleration (Force$$anonymous$$ode.Acceleration) or a velocity change (Force$$anonymous$$ode.VelocityChange) is often an easier method of control.
Should also note that if you compute your own forces/accelerations, it's probably a bad idea to do it in Update(), since the time step can change. Do it in FixedUpdate ins$$anonymous$$d.
Answer by DallonF · May 26, 2010 at 05:19 PM
I believe I'd heard that 50 units of force translates to 1 unit of distance per second per second.
I ran into a similar situation where i needed to know precise units for thrust, so I ran an experiment. Earths gravity, and the Unity default, is -9.81 Newtons, and so, in order for a 1kg object to float, i.e. counteract gravity, it should require +9.81 newtons of force. However, calling AddForce(0, 9.81f, 0) doesn't cut it, your object will still fall.
Turns out DallonF was on the right track, because if you add 50 * 9.81 of thrust, your object will float. So I suppose the units for thrust are actually 1/50th of a Newton...
This might be a little late but i've found that by multiplying the gravity by the mass of the rigidbody, and object can stay floating.
Actually, this number 50 is related to the frequency of FixedUpdate, by default 50 times per second. I believe that "a continuous force" is just independce with time. It means that if we want to apply Force$$anonymous$$ode.Force, we need to call this function in 1 second, for each FixedUpdate, this force automatic reduced by 50, and in total: F/50*50 = F If we can some how change the frequency of FixedUpdate, Force$$anonymous$$ode.Force still the same in 1 second, but Force$$anonymous$$ode.Impulse will affect in longer/shotert time duration of 1 fixed frame (and because Impulse only affect in 1 frame)
I've had different results in my tests: When using AddForce(..., Force$$anonymous$$ode.Force)
, I can get an object to float by using exactly 9.81f * rigidbody.mass
. There does not seem to be any need to consider the Time.deltaTime
when doing this in FixedUpdate
. This is with Unity 4.3.4.
Your answer
Follow this Question
Related Questions
2D 360 degress platformer example needed 0 Answers
addforce seems inconsistant 4 Answers
Why are these object passing through each other? 1 Answer
Why Am I Falling So Slow? 1 Answer
Trying to get a character to bounce off a platform 2 Answers