Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Josp101 · Oct 26, 2016 at 10:29 PM · physicsgravityspacesimulationcalculations

How do you create a continuous physics simulation in Unity?

So I want to make a game with planets (and other celestial objects) orbiting stars (and other stuff).

I want to be able to predict the path of an object in the future and display where it is going to move. I know that the 'n-body problem' is unsolved, so only small objects that won't exert any force of gravity will be actually move - all other objects will have fixed positions.

So basically the force (and therefore the acceleration) of any of my moving objects will be a function of position. But now I want to predict their paths. I want to do this with calculus, so that I can get an exact value for an object's position at any given time, without making lots of expensive calculations.

However, since Unity does not have built in functionality for this kind of simulation, I am going to have to set the force on the moving objects each frame in FixedUpdate() based on their masses and positions relative to the gravity-exerting stars. This means there will always be a constant force on an object throughout a single Physics Time-step. Therefore, my calculation that predicts the position of the object at any given time using calculus will not be accurate because it assumes a continuous change of force based on continuous movement.

Is the only solution to essentially create my own physics system that uses calculus to work with continuous gravitational forces from the stars and use this to set the position of each moving object directly each frame?

/*Side Note: I was also thinking about other possible scenarios in the physics engine and I was wondering how this issue is solved in other cases.

Presumably Unity's physics engine sometimes has to work with forces (and torques etc.) that should change throughout a Physics Time-step. (Eg. Collisions?)

How does Unity handle this? Does it just approximate that the force would stay constant through out the Time-step and calculate what would happen with constant values of all the variables.*/

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 rollothedog · Oct 30, 2016 at 05:57 PM 0
Share

OH $$anonymous$$Y GOD!!!! FFINALLY SO$$anonymous$$EONE ELSE SHARES $$anonymous$$Y PROBLE$$anonymous$$!! I have BEEN WONDERING HOW TO CREATE A CONTINUOS FYSICS SI$$anonymous$$ULATION FOR SO LONG. I really hope some brave brvae sole has the knowledge requiered to answer this BEAUTIFULL question. PLEEEEEEESE CAN YOU PLASESSSE ANSWER THIS A$$anonymous$$AZING QUESTION PLEASE!!! :):):):):):):):):) feeling happy

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by tanoshimi · Oct 30, 2016 at 06:39 PM

Physics in Unity is implemented using the NVidia PhsyX engine. You can read all about it at http://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/Introduction.html, but one section you might want to note (in the "Physics vs PhysX" section) reads as follows:

"PhysX is best suited for quasi-real time interactive 3D applications where performance and scalability are more important than precision. Here "quasi-real time" means that advancing a PhysX simulation by a given time step, say 1/60 second, will take less than that amount of time on an observer's clock if the performance of the hardware platform is sufficient for the complexity of the simulation. That the PhysX SDK is more widely used in computer and video games than in scientific or engineering applications is both a cause and an effect of these design choices."

So, to answer your other question, if you want to implement a continuous system, yes you'll have to code it yourself.

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 Josp101 · Nov 03, 2016 at 10:16 PM 0
Share

Thanks very much for your answer (sorry I took so long to respond - I had an exam :) )

That's definitely an interesting read

 In contrast, time in a PhysX simulation is discrete, not continuous, and it runs only 'forwards'. That is, the state of the simulated system is known only at specific instants in time, usually referred to as 'steps', and the simulation may only step forwards in time, never backwards. The state of a PhysX system in between time steps is not precisely deter$$anonymous$$ed.

I think that's the key info. It seems that PhysX is basically a bit different from real physics. I'm still not entirely sure about how 'continuous vs discrete' works in general with the engine, because it does have a feature called 'continuous collision detection'.

But yes, it looks like I'll have to make my own physics for this problem :)

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

calculate the future position of an object in orbit 1 Answer

Help with orbits 1 Answer

Point gravity implementation lacks precision 2 Answers

Player in Spaceship 2 Answers

Handling Large number of Active Rigidbody Evaluations 2 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