- Home /
Trying to Understand Rigidbody ForceMode Derivation
Hello everyone, I am trying to get a better understanding how the ForceMode formulas work (not "What they do") with Rigidbody.AddForce().
Take for example Acceleration and VelocityChange, both of which ignore mass to makes things more simple. Lets also say that my added velocity is (0,0,0.1).
I observe that Acceleration will take 1 second to apply the full force, and VelocityChange will do the same each Fixed Update. What I don't understand is the formula used to derive the difference (and I fully appreciate I just may be doing / understanding the math completely wrong).
Acceleration uses distance/time^2 (0.1/0.02^2). Which, using the vector above gives (0,0,250)...huh? VelocityChange uses distance/time (0.1/0.2). Which, using the vector above comes to (0,0,5)...again, what?
I don't understand how the values outputted by the formula ends up moving the rigidbody in the way it does. Any clarification is greatly appreciated.
@boddole Please accept the answer that answered your question. If you don't know how, watch the tutorial video on the right.
Answer by Benproductions1 · Oct 03, 2014 at 09:21 AM
You're confusing the difference between a unit and a formula. It might be helpful if you understood the basics of physics, aka classical mechanics. You might also want to read the documentation of each of the force modes more carefully. ForceMode.Acceleration
is over a period of time, while VelocityChange
is instance (which is not what you described).
Answer by Bunny83 · Oct 04, 2014 at 02:46 AM
Like Ben said it's all straight forward:
ForceMode.VelocityChange does exactly what the name suggests. So those two lines do exactly the same:
// The passed "force" parameter is in m/s which is added instantly to the velocity
rigidbody.AddForce(Vector3.forward*1.0f,ForceMode.VelocityChange);
rigidbody.velocity += Vector3.forward*1.0f;
ForceMode.Acceleration is ment to be applied every FixedUpdate. So the result you get after 1 second is the same as VelocityChange. The next two lines are exactly the same:
// The passed "force" is in m/s². If applied every fixed frame the accumulated velocity will increased by "force" m/s every second
rigidbody.AddForce(Vector3.forward*1.0f,ForceMode.Acceleration);
rigidbody.velocity += Vector3.forward*1.0f * Time.fixedDeltaTime;
ForceMode.Force and ForceMode.Impulse just do the same but also divide by the mass of the object:
// "force" is in newton (kg*m/s²)
rigidbody.AddForce(Vector3.forward*1.0f,ForceMode.Force);
rigidbody.velocity += Vector3.forward*1.0f * Time.fixedDeltaTime / (rigidbody.mass);
ForceMode.Impulse:
// "force" is a impulse / momentum which is in kg*m/s
rigidbody.AddForce(Vector3.forward*1.0f,ForceMode.Impulse);
rigidbody.velocity += Vector3.forward*1.0f / rigidbody.mass;
edit
Two quick crosslinks to how drag is applied:
Based on your answer, I created drawings to help you understand AddForce ()
If someone stops by, please keep in $$anonymous$$d that you can vote comments too, thank you ^^.
Answer by Clonkex · Nov 14, 2015 at 12:57 PM
If you're still confused for any reason, I asked a similar question with some good answers:
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Addforce - bug with jump 2 Answers
How would I get collision at different speeds? 2 Answers
Strange Rigidbody Behavior 0 Answers
Can i ignore a rigidbody in my Raycast? 0 Answers