Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
1
Question by lh · Dec 10, 2014 at 06:49 AM · physicsdragaccelerationfriction

Where can I find details on the physics engine?

I have just one question, everything else I write is just to satisfy your curiosity. My question is: How can I find out exactly how Unity evaluates forces, velocity, friction and drag to calculate the next velocity and object position?

I'm having trouble with object movement. The variables at play are drag, friction via PhysicMaterials and using a lot of rigidbody.AddForce(dir, ForceMode.VelocityChange). The biggest problem is that doing this work in the Update loop yields different results for different framerates, but in theory it should not, because logic like this is as simple as it gets:

 velocity += deltaTime * acceleration

The above is a great example because it's easy to debug. The problem is that the velocity getter is not updated until the FixedUpdate loop, so adding several different values to velocity will just continually use the old value.

 rigidbody.velocity += explosionA;
 rigidbody.velocity += explosionB;

The above does not yield the expected result, because velocity is precalculated. It comes out to be the same as the following:

 Vector3 cachedVelocity = rigidbody.velocity;
 rigidbody.velocity = cachedVelocity + explosionA;
 rigidbody.velocity = cachedVelocity + explosionB;

My bigger problem is that it's hard to get movement speed and acceleration quite right, since the game is using a mish-mash of built in physics and manual controls to get everything "just right".

Comment
Add comment · Show 1
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 taxvi · Dec 10, 2014 at 07:09 AM 0
Share

well, I never had the same problem, try looking at The Execution Order

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by tanoshimi · Dec 10, 2014 at 07:42 AM

Unity uses the PhysX engine. I don't think you'll find a simple one-line "this is how we resolve forces", but you could try looking at the developer documentation there: http://www.geforce.com/hardware/technology/physx

Comment
Add comment · Show 1 · 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 Kiwasi · Dec 10, 2014 at 10:38 AM 0
Share

Also worth noting that the exact implementation of PhysX is propriety. NVIDIA makes a lot of money off having the most efficient, widely implemented engine. They are hardly going to give it away.

avatar image
2

Answer by Bunny83 · Dec 10, 2014 at 08:03 AM

Physics is a complex topic an a lot variables can't be predicted (like most collision based stuff). If you want to know how (manual) forces and drag are applied see my answer over here (and the linked one). For information how the bouncing values in your physics material are combined see this question.

However things like friction and complex collisions (which involve angularVelocity as well as linear velocity) are way more complex and can't be predicted / calculated that easy.

Also you should do everything physics related in FixedUpdate. Update in combination with Time.deltaTime only works for linear equations. Everything more complex can't be "corrected" with a linear scalar like deltaTime. A quadratic equation "fixed" with deltaTime is almost correct. However the slower your Update runs the larger is the error. Using FixedUpdate ensures at least a contant behaviour since you have a constant framerate.

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

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

27 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

Related Questions

Convert rigidbody.drag to acceleration(m/s²)? 0 Answers

Realistic methods of propulsion without friction involved 0 Answers

Overcome drag 1 Answer

arrows in unity 3d? 0 Answers

Help with DragRigidbody.js ? 1 Answer


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