• 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 /
  • Help Room /
avatar image
0
Question by robertwakeling82 · Jul 27, 2019 at 06:59 AM · physics

How accurate are the physics?

Hi everyone, I'm trying to simulate some projectile mechanics and the results are pretty good but I'd like to do better if possible. I have a sphere radius 1 and I add a Force in the y direction using Impulse mode; when I calculate the speed (magnitude) upon return to ground, it is not the same. It may be a problem in my code but if the rotation is frozen and positions are locked in x and z (drag and angular drag are disabled), it should be the same. For example, I 'launch' at 15 and it returns at 14.8 on the Debug.Log. I am using Update method, is that a possible issue or do I accept that there is some error in this? Many thanks in advance for your comments.

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
0
Best Answer

Answer by Captain_Pineapple · Jul 27, 2019 at 07:10 AM

Hey there, in general the calculations are limited by 2 factors: floating point precision and the fact that you are in a discrete world. So there will be errors.


floating point precision will not be a huge factor when it comes to your example. that gets a bit more of a hassle when you move a projectile 1000000 units. There you will notice significant impacts.


the discretized world is more of an issue. Unity calculates all positions/rotations/velocities/accellerations new on every FixedUpdate. Which is every 0.02 seconds. This makes stuff look good enough but might result in some minor inaccuracies. Your 0.2 difference in speed probably result from one of these discrete steps and probably is connected to your choice of collision check method.(dicsrete, continuous, continuous dynamic ... ) Perhaps another method will let your "projectile" move a bit further getting it to the full 15 speed again. You can also try to play with the physics settings to get higher accuracies - but beware of the performance cost that it comes with. For example you could lower the collision thresholds, raise the fixed update rate and raise the physics solver iteration count. If i remember correctly the documentation on this actually was fairly good.


Hope this answers some stuff, if there are more questions on this let me know.

Cheers.

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 robertwakeling82 · Jul 27, 2019 at 07:17 AM 0
Share

Thank you very much for your information. So with Physics, I should be using FixedUpdate? I will check the collision type too; upon testing I'm noticing that the sphere appears to be embedding into the ground somewhat too i.e. its y position becomes slightly negative. Perhaps it's behaving like a bullet going into a wall or something. I'll see if there are ways to stop the particle dead in its tracks as opposed to doing this type of behaviour (which is pretty cool if I'm reading it right but not the effect I'm after). I thought that maybe the velocity was above 15 and it's quickly going lower but that's not the case and maybe limited by my laptop which is pretty rubbish and just missing 15 m/s frame?

avatar image Captain_Pineapple robertwakeling82 · Jul 27, 2019 at 07:47 AM 0
Share

First things first: For all physics related stuff unity proposes to use Fixed update. (Adding force and so on) Normal update might also work but might also result in some weird behaviour.


when you see something "slightly" in another collider -> there is no perfect collision. As i mentioned above there is something called a "collision threshold". That is the distance or "area" in which unity will just say: yeah there is a collision, even though there is still this little little bit distance left.


When you say "missing the 15 m/s frame": yes and no. There is no guarantee that this frame actually exists. When you divide the movement in timeslices of 0.02 seconds you might end up at 14.8 in one frame and then 15.6 in the next or something like that.


In general remember to not do too much in the fixed update. since it has to run every 0.02 seconds keep it slim and don't do things that are heavy on performance here.

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

251 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 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 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 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 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 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

Collision detection glitch 1 Answer

Is it possible to make Unity portable? 1 Answer

How to make physics for rail trolley with gravity changing. Unity 2d game 0 Answers

Sumo Physics Bounce Question 0 Answers

How to specifically arrange only 'Mesh Collider' to be hit by Raycast? 0 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