Answers for "Force to Velocity scaling?"
http://answers.unity.com/questions/819273/force-to-velocity-scaling.html
The latest answers for the question "Force to Velocity scaling?"Answer by Bunny83
http://answers.unity.com/answers/819474/view.html
You might want to read [my answer over here][1]
***edit***
In addition to my answer about how AddForce actually works, here's how the drag is applied (at least in version 4.5.4f1):
velocity *= Mathf.Clamp01(1f - drag * Time.fixedDeltaTime);
You might want to read my [post on the forum][2] where i explain it a bit more in detail.
***second edit***
If you want to use Unity's drag system, here are 6 helper methods to calculate:
- the final velocity you might reach for a given acceleration / velocityChange and drag value.
- the drag value required for a given acceleration / velocityChange to reach the desired velocity.
- the acceleration / velocityChange required to reach the desired velocity with a given drag value
You could extend each pair of methods to work with an actual force / impulse value. Keep in mind those methods only work for an acceperation / velocity change applied each FixedUpdate. One-time changes are pointless since you will have the final velocity at the moment you apply the force / acceleration / change. The drag will simply pull it back to 0.
//C#
float GetFinalVelocity(float aVelocityChange, float aDrag)
{
return aVelocityChange * (1 / Mathf.Clamp01(aDrag * Time.fixedDeltaTime) - 1);
}
float GetFinalVelocityFromAcceleration(float aAcceleration, float aDrag)
{
return GetFinalVelocity(aAcceleration * Time.fixedDeltaTime, aDrag);
}
float GetDrag(float aVelocityChange, float aFinalVelocity)
{
return aVelocityChange / ((aFinalVelocity + aVelocityChange) * Time.fixedDeltaTime);
}
float GetDragFromAcceleration(float aAcceleration, float aFinalVelocity)
{
return GetDrag(aAcceleration * Time.fixedDeltaTime, aFinalVelocity);
}
float GetRequiredVelocityChange(float aFinalSpeed, float aDrag)
{
float m = Mathf.Clamp01(aDrag * Time.fixedDeltaTime);
return aFinalSpeed * m / (1 - m);
}
float GetRequiredAcceleraton(float aFinalSpeed, float aDrag)
{
return GetRequiredVelocityChange(aFinalSpeed, aDrag) / Time.fixedDeltaTime;
}
Final note: In case a constant force is applied with a drag value > 0, the velocity will slowly get closer to the final velocity but [won't actually reach it][3]. However due to floating point precision the remaining difference will usually be "rounded away" within seconds.
Also keep in mind that in case your drag value is greater than the fixed framerate, functions like GetRequiredAcceleraton will return infinity as there is no acceleration to reach the given speed.
[1]: http://answers.unity3d.com/questions/802181/trying-to-understand-rigidbody-forcemode-derivatio.html#answer-802667
[2]: http://forum.unity3d.com/threads/drag-factor-what-is-it.85504/#post-1827892
[3]: http://en.wikipedia.org/wiki/AsymptoteTue, 28 Oct 2014 19:58:12 GMTBunny83Answer by Kiwasi
http://answers.unity.com/answers/819444/view.html
There's this guy called Newton? Maybe you've heard of him.
Anyway the correct formula is force = mass * acceleration.
There are lots of other formulas to try. Google Newtonian physics. Or classical physics.Tue, 28 Oct 2014 19:20:49 GMTKiwasi