• 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
0
Question by Azzara. · Jun 02, 2013 at 03:01 PM · velocityaddforceaccelerationdisplacementconstant force

Constant force motion: s = s0 + v0 * t + a0 * t * t. Why?

I have a rigid body with with an absolute constant force (100, 0, 0). I am trying to predict the next position of the rigid body. The mass is equal to 1 so the constant force and the acceleration are the same.

According to Wikipedia the end displacement s should be

 s = s0 + v0 * t + a0 * t * t / 2;

where s0, v0 and a0 are the initial displacement, velocity and acceleration. And t is the time interval (Time.fixedDeltaTime in Unity).

For some reason the correct displacement formula in Unity is

 s = s0 + v0 * t + a0 * t * t;

I am trying to figure out why. I've tested this using a simple script with a FixedUpdate() method which logs the current position to the console.

     Vector2 s0 = transform.position;
     Vector2 v0 = rigidbody.velocity;
     Vector2 a0 = constantForce.force;
 
     float dt = Time.fixedDeltaTime;
     Vector2 dsV = dt * v0;
     Vector2 dsA = 1.0f * dt * dt * a0;
     Vector2 s1 = s0 + dsV + dsA;
 
     Debug.Log("DSIP X: " + s0.x + " + " + dsV.x + " + " + dsA.x + " = " + s1.x + "       @ " + Time.time);

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

1 Reply

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

Answer by Owen-Reynolds · Jun 02, 2013 at 04:18 PM

Wikipedia is giving you the calculus equation, which assumes an infinite small time step (the basic principle of calculus.)

In any step-based physics system, you have to decide whether to add force at the start or the end of the time step. One moves you a little too fast, the other a little too slow. If you tested over many frames, you'd see that Unity is probably just a tiny bit over the correct value. If you could run Unity at 1000, 10000 ... frames/sec, you'd see it getting closer and closer to the real value (again, definition of calculus.)

It's the same as the rectangle method of calculating area under a curve (at the start of any calculus text.) Each rectangle either goes up to the lowest part of the curve, or the highest, which will under/over estimate the area. As the rectangles get thinner (which is like more time steps,) they both squeeze to the real value.

Comment
Add comment · Show 2 · 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 aldonaletto · Jun 02, 2013 at 05:04 PM 0
Share

That's right: position should be calculated in Unity with the wiki's equation, but doing this each frame may produce weird errors due to the discrete nature of physics emulation. Try to calculate the position 100 frames ahead, for instance (100 * t) and compare to the actual position after 100 frames: you will see that they're very close.

avatar image Azzara. · Jun 02, 2013 at 05:09 PM 0
Share

I didn't realize Unity applies the forces at the beginning. I'll keep that in $$anonymous$$d from now on.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

Problem matching particle & object velocities + speed 2 Answers

Obtaining Constant Speed with AddForce 1 Answer

Accelerate a rigidbody towards max speed 2 Answers

different beetween transform.translat and rigidbody.addforce? 1 Answer

Insure that the player can't increase speed when over the speed limit 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