• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
23
Question by Clonkex · Apr 27, 2014 at 11:41 PM · physicsforcemode

Difference between ForceMode.Force/Acceleration/Impulse/VelocityChange?

What is the difference between the four modes of ForceMode? I don't understand how you can apply a force in multiple ways. For example, if I put my hand on a car and push with a specific amount of force for 5 frames, what's the difference to hitting it with the same amount of force once each frame for 5 frames?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

8 Replies

· Add your reply
  • Sort: 
avatar image
55
Best Answer

Answer by Clonkex · Nov 14, 2015 at 12:37 PM

History Lesson (not really)

Ok, so more than a year later I've had the need to come back and attempt to fully understand this problem (as I never really understood what the differences were). After staring at the formulae for a long time and not really getting anywhere, I decided to stare at the page linked by @jchangxu (thanks btw!). After a short while, one phrase jumped out at me: Think of it as 'Force exerted per second'

Instantly I realised I understood the differences. It's actually really simple, but everyone makes it sound so complicated that you assume it's more complicated than it really is. Since no one has yet managed to explain it clearly, here's my attempt from the viewpoint of someone who's only just figured it out.

Incidentally: The official documentation could do with a better explanation since the current explanation in the docs is crappy and doesn't actually tell you anything unless you do the maths yourself, and even then the maths alone doesn't tell you everything about the function.


tl;dr (...or "The Boy That Couldn't Be Bothered")

 ForceMode.Force == Force per second
 ForceMode.Impulse == Force per frame

There's no actual difference in the way Force and Impulse apply the forces, only in how they calculate the amount of force to apply. If you do Force once every FixedUpdate for exactly one second, you will have applied the same amount of total force as doing Impulse on just one frame.


Longer Explanation (for maximum understandings)

The real difference is that Force treats the force parameter as Newtons and Impulse treats the force parameter as Newton-seconds, but we don't need to understand that to have a good understanding of how to use the function.


Force is calculated as:

 Acceleration = Force * Time ^ 2 / Mass

Thus if the object has a mass of 2, you apply a force of 40 and the fixed timestep is left at the default of 0.02, it will look like this:

 Acceleration = 40 * (0.02 * 0.02) / 2
 Acceleration = 40 * 0.0004 / 2
 Acceleration = 0.016 / 2
 Acceleration = 0.008

So the object will gain 0.008 metres per second of velocity. In other words, it will accelerate by 0.008m/s.


Impulse is calculated as:

 Acceleration = Force * Time / Mass

Thus if the object has a mass of 2, you apply a force of 40 and the fixed timestep is left at the default of 0.02, it will look like this:

 Acceleration = 40 * 0.02 / 2
 Acceleration = 0.8 / 2
 Acceleration = 0.4

So the object will accelerate by 0.4m/s.


Notice that 0.4 is exactly 50 * 0.008 (50 being the default number of timesteps in a second). That's because Force treats your force input as force per second, whereas Impulse treats your force input as force per timestep.

The other two ForceModes, Acceleration and VelocityChange, are even simpler because they leave mass out of the equation.


Acceleration is calculated as:

 Acceleration = Force * Time ^ 2

Thus, regardless of the object's mass, if you apply a force of 40 and the fixed timestep is left at the default of 0.02, it will look like this:

 Acceleration = 40 * (0.02 * 0.02)
 Acceleration = 40 * 0.0004 
 Acceleration = 0.016

So the object will accelerate by 0.16m/s.


VelocityChange is calculated as:

 Acceleration = Force * Time

Thus, regardless of the object's mass, if you apply a force of 40 and the fixed timestep is left at the default of 0.02, it will look like this:

 Acceleration = 40 * 0.02
 Acceleration = 0.8

So the object will accelerate by 0.8m/s.


And finally, it's worth saying it again, just to be clear: no matter which ForceMode you choose, the force will not be applied on subsequent frames automatically. It will only be applied at the instant you call the function. The difference is simply in how it calculates how much force to apply, not in how it applies the force.

Comment
Add comment · Show 28 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Clonkex · Nov 14, 2015 at 01:00 PM 0
Share

If someone reckons this answer isn't correct in any way, please say so and explain why you say that. Thanks!

avatar image jimmy12day Clonkex · Apr 07, 2021 at 06:58 PM 0
Share

Saying “ForceMode.Impulse == Force per frame” is totally wrong. The author even realized it by himself by saying "It will only be applied at the instant you call the function".


I am tired to explain this again, Unity physics is bad physics because those Forcemodes were not correctly implemented as it sounds.


Basically, they are all the same method, two of them have 50x speed(50 physics frame in a second) multiplier, two of them include Mass.

avatar image Clonkex jimmy12day · 3 hours ago 1
Share

It's not totally wrong. It's "force per frame" but only if you keep applying it every frame. It's talking about the units in use, not the behaviour of the function.

When you say "Unity physics" do you mean the new DOTS physics engine? Because the regular physics engine that's existed for years is Nvidia PhysX.

Your last sentence is exactly right. They all do the same thing, and we could easily achieve the same result with only one function and some maths on our end.

Show more comments
avatar image mgto · Jan 12, 2016 at 07:26 AM 0
Share

Your answer is good but there is one problem in the way you describe the effect.

So Force$$anonymous$$ode.Impulse is applying 50 per frame

50 what?

What you are currently doing when using AddForce() is not applying a 'distance' but:

  • Force$$anonymous$$ode.Impulse: you're applying an Impulse in Newton Seconds (Ns)

  • Force$$anonymous$$ode.Force: you're applying a Force in Newton (N)

If you're applying a Force of 5 (or an Impulse of 5) that's it. You don't have to calculate the actual force.

BUT if you want to know how big delta_s or delta_v are (the relative change in distance / velocity) you can use (for example) the formulas you've posted to calculate the values.

So if you have an Impulse of 5 Ns your object will travel 5 * 0.1 / 1 = 0.5 (relative) units after applying the impulse.

If you have a Force of 5 N your object will travel 5 * 0.1^2 / 1 = 0.05 (relative) units after applying the force for one frame and 0.5 (relative) units after applying it for 10 frames and 5 (relative) units after applying it for 100 frames etc.

I always write 'relative' because it always depends on the start conditions how the objects absolute movement will look like

avatar image HeavyStorm · Mar 09, 2016 at 07:29 PM 0
Share

I'm pretty sure where you typed 1 x 5 / 0.1 x 0.1 you meant 1 x 5 / (0.1 x 0.1), after all the math is based on the square of delta time, which would be 1 x 5 / 0.1^2. So the total force applied would be 500, not 5.

avatar image Clonkex HeavyStorm · Sep 28, 2020 at 01:05 AM 0
Share

500 force would be incorrect, and I didn't mean 1 x 5 / (0.1 x 0.1). At the time I assumed that internally it was treating time^2 as time * time, even though that would mean the manual's mass*distance/time^2 was incorrect to how it actually worked. In reality I was using mass*distance/time^2 incorrectly and it was just coincidence that it worked out if I did 1 * 5 / 0.1 * 0.1. I'll update my answer with the correct maths if I can find the time this weekend (the difficulty being that the correct maths is more complicated and I want the answer to remain easy to understand).

avatar image jimmy12day Clonkex · Apr 07, 2021 at 07:02 PM 0
Share

Dear Clonkex, your solutions are voted most, can you rewrite it in a simpler paragram please? Please take a chance to look at my explanations also.

Show more comments
avatar image oscarAbraham · Jun 07, 2019 at 07:26 PM 3
Share

This gets on top results on google, so I thought I'd clarify something. In spirit, this is right, but not in maths:


So the formula for force is force = mass * acceleration, that can be understood also as force = mass * (distance / time^2) When we input a force to the function, we are not using the formula like that, though. We already know the value for force, what we need is the value for acceleration. So the formula we are using is acceleration=force/mass.


For example, if our force is 5 and our mass is 1, then we get that acceleration = 5 / 1. So, Acceleration would be 5. That means our object's velocity would be augmented by 5. The problem is that we don't know over how much time our velocity would be augmented that much. Unity uses seconds as a time unit, should the velocity change be applied over a whole second? On the other hand, we are calling the function right now, to simulate what happens over a specific timeStep, should the velocity change be applied over this timeStep?


In Force mode, the value that we pass is in newtons. A newton is equal to 1kg * 1m/s^2. That means that if this force is applied to an object with a mass of one kilogram over one second, its velocity will been have augmented by one meter per second. Since our function is calculated on the fixed time step, the object's velocity will only be augmented as if the force was applied over that amount of time. In our previous example, if the fixed time step is .1 seconds, the velocity would be augmented by 5*.1, that means .5.


In Impulse mode, we say to the function: "Whatever the time step, I wan't the velocity change that would be applied in a second to be applied NOW". So our value is passed in units of 1kg * 1m/(s*timeStep). That means that if this force is applied to an object with a mass of one kilogram over one timeStep, its velocity will been have augmented by one meter per second. In our example, the velocity would be augmented by 5 each time the function is called.


Another way of thinking about it is that acceleration = velocityChange/time, that's why time is squared in the answer's formula, because distance/time/time = distance/time^2. Anyway, that means that velocityChange = acceleration*time. So in our example, if we are using Force mode, our time is .1 seconds (so it's 5*.1); but, if we are using Impulse mode, our time is 1 timeStep (so it's 5*1).

avatar image Clonkex oscarAbraham · Sep 28, 2020 at 12:59 AM 0
Share

It seems like you're co$$anonymous$$g at this from a physicist's perspective, but the problem is that as game programmers the majority of us don't see it that way. For instance:

The problem is that we don't know over how much time our velocity would be augmented that much. Unity uses seconds as a time unit, should the velocity change be applied over a whole second? On the other hand, we are calling the function right now, to simulate what happens over a specific timeStep, should the velocity change be applied over this timeStep?

That's essentially meaningless to me. Game physics simulations are processed in discrete steps, and they don't apply forces continuously over a period of time, so changes don't happen "over a whole second" or "over a specific timestep". They happen instantaneously, over no time at all. Boiled down, the only thing I care about is how much the object's velocity will change in this timestep, and whether the function will continue to have any effect on subsequent frames even if I don't call it again.


I'm also a little confused about your maths, because distance / time / time != distance / time ^ 2, unless you have a very different definition of exponents than I do.


Otherwise I do see that my maths is technically incorrect, and the only reason it works out is coincidence. I'll try to find the time to update this answer, but of course I'll need to figure out how to explain it well enough that it doesn't make it more confusing.

avatar image DeadlyArtist Clonkex · Oct 15, 2020 at 02:35 AM 1
Share

distance / time / time == distance / time ^ 2


because distance / time / time == distance / (time * time) == distance / time^2


because of how math works you do from left to right and ^ before * before + pls update i instantly noticed the error and others do as well and then they are confused

Show more comments
Show more comments
avatar image gillemp · Jun 09, 2020 at 03:58 PM 5
Share

I created this table from your answer so it is even simpler and quick to read: alt text

avatar image Clonkex gillemp · Sep 28, 2020 at 01:01 AM 0
Share

Personally I find this just as confusing as the manual's original explanation. The key problem here is that it makes it sound like .Force and .Acceleration will continue to apply the force over 1 second's worth of frames, when in reality they don't do anything past the single frame where you call them.

avatar image DeadlyArtist gillemp · Oct 15, 2020 at 02:12 AM 1
Share

Honestly by far best explanation. Literally says everything there is to it in an intuitive format. Best UX.

Seeing this pretty much confirmed my suspicions though: Force and Acceleration are utterly useless and it's better to just make a script that manages your object's velocity. I don't see a single reason for Force and Acceleration to even exist.

avatar image Tortuap DeadlyArtist · Oct 15, 2020 at 08:17 AM 2
Share

They are all useful, it's a matter of how you express and manipulate your values. If you manipulate values over seconds (speed) then you wan't to use Force or Acceleration. If you express values over a frame then you'll use Velocity or Impulse.

Show more comments
Show more comments
avatar image
1

Answer by jimmy12day · Sep 24, 2020 at 09:06 AM

I created a cuboid in Unity and added rigidbody to the cuboid. Disabled gravity. Wrote a movable scrpit in Start() method to test the differences between these 4 forcemodes. Below is my test results and summary.


Equations

  • ForceMode.VelocityChange = Number of Force

  • ForceMode.Acceleration = Number of Force / PhysicsFramerate

  • ForceMode.Impulse = Number of Force / Mass

  • ForceMode.Force = Number of Force / Mass / PhysicsFramerate


Example

[ForceMultiplier= 200]

[Mass = 2 ]

[PhysicsFramerate = 50]

  • ForceMode.VelocityChange = 200= 200

  • ForceMode.Acceleration = 200 / 50 = 4

  • ForceMode.Impulse = 200 / 2 = 100

  • ForceMode.Force = 200 / 2 / 50 = 2


Explanation

  • Any force was effective in 1 second only. So if you call the force in the Start() method, it only applies 1 second. But it will apply every second in the Update()/FixedUpdate() method.

  • Unity locked the PhysicsFramerate to 50 frames per second (This is different from your application's framerate), which does not change.

  • If no other force applied(e.g. gravity), the speed will remain the same after the force applied.

  • Time.deltaTime represents the actual frame time, which can be used to make the acceleration smoother.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jimmy12day · Apr 07, 2021 at 08:00 AM 0
Share

Unity physics is very tricky, it is not real physics. In my unity test project, the speed increased immediately to the final speed instead of accelerating bit by bit over time. So I will suggest not to use unity physics for serious simulations.

avatar image oscarAbraham jimmy12day · Jun 26, 2021 at 04:28 PM 0
Share

I'm not disagreeing that the physics engine, which is Nvidia PhysX, shouldn't be used for very serious stuff; stuff like landing a rocket or plane safety simulations. What you're describing shouldn't happen if done properly, though. What was your code?

avatar image Clonkex jimmy12day · 3 hours ago 0
Share

Unity physics is as close to real physics as a game physics engine gets. It sounds like you just don't understand how to use it.

avatar image
1

Answer by Leohoran · Aug 30, 2020 at 02:57 PM

My final answer

ForceMode.Force = Time.fixedDeltaTime * ForceMode.Impulse

ForceMode.Acceleration = Time.fixedDeltaTime * ForceMode.VelocityChange


ForceMode.Force = mass * velocityChange / timeChange

ForceMode.Impulse = mass * velocityChange / timeChange / Time.fixedDeltaTime

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by unity_qbQrrkGO2DjFvA · Aug 25, 2020 at 01:20 PM

Let's talk a little about physics.


Equations: Force = mass * acceleration, F = ma Impulse = change in momentum, J = (delta) mv Force = Impulse/time. = F = J/t


First, understand that adding an instant force or acceleration is mathematically impossible, so Unity applies the force/acceleration gradually over a time period for ForceMode.Force and ForceMode.Acceleration. This time period is normally 1 second. (meaning it technically adds an impulse... but enough of that)

Secondly, adding an instant impulse is mathematically possible because an impulse is a force applied over a time period. Same with ForceMode.VelocityChange.


Key: m = rigidbody mass Q = Vector3 number parameter t = Force application duration, normally 1 second in Unity


ForceMode.Force adds the exact force on the object on that Frame. Therefore, the rigidbody the force is exerted on will accelerate at an acceleration of Q/m for t seconds. If you know your integrals... acceleration is the first derivative of velocity and so the velocity of the object will gradually change by (Q/m)*t = Q/m for 1 second.


ForceMode.Impulse adds an instant impulse on the object on that frame. An impulse changes the momentum of the object, and because the mass stays the same, the velocity of the object instantly changes by Q/m.


ForceMode.Acceleration directly adds an acceleration to the object, regardless of its mass. So the change in velocity of the object becomes Qt = Q for 1 second. Equivalent to applying a ForceMode.Force of m*Q.


ForceMode.Velocity instantly changes the velocity of the object by Q, regardless of its mass. Equivalent of applying an Impulse of m*Q.



Summary: the main difference is whether the amount is applied instantly or not. Impulse and VelocityChange are instant (therefore not realistic in real life), ForceMode.Force and ForceMode.Acceleration are gradual along 1 second (but are misleading in name).

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
4

Answer by LouisHong · May 22, 2018 at 01:52 PM

ForceMode.Acceleration is ForceMode.VelocityChange but mutiplied by Time.fixedDeltaTime


ForceMode.VelocityChange just changes velocity by force parameter


ForceMode.Impulse changes velocity by force / mass


ForceMode.Force changes velocity by force / mass * Time.fixedDeltaTime


They should just write this as the unity documentation for ForceMode, hope you found it useful

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MrLeaky · Feb 06, 2019 at 09:05 AM 1
Share

Exactly; this is a great way to summarize it. The documentation is totally confusing, and their bloated, unreadably formatted (i.e. no proper syntax highlight) example code is not helpful at all.

avatar image Tortuap · Sep 27, 2020 at 09:03 PM 0
Share

Force$$anonymous$$ode.Force changes velocity by force / mass * Time.fixedDeltaTime, no ?

avatar image Owen-Reynolds Tortuap · Sep 27, 2020 at 09:13 PM 0
Share

Yes. Every mode is the same: a 1-time change to velocity. The only difference is the amount they change it by.

avatar image Bunny83 Tortuap · Sep 28, 2020 at 12:20 AM 0
Share

There was a similar question like this from the same year and I gave a pretty clear explanation I_m sure Louis wanted to say "velocity" and not "acceleration". I'll edit this answer to fix it.

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

45 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

ForceMode.VelocityChange vs. simply adding to .velocity 0 Answers

Physics object slides while turning. 1 Answer

Trouble with spring platform 0 Answers

Foces only change during collision 1 Answer

Trying to Understand Rigidbody ForceMode Derivation 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges