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 al-X · Sep 05, 2019 at 12:08 AM · physicsgravityspaceorbitsimulation

calculate the future position of an object in orbit

I'm developing a game that relies on some basic orbital physics, they don't have to be exact but a close approximation would be nice. yes, a nice and tidy Kepler orbit.

I used newtons law -(G M m)/r and a unit vector {x,y,z}/ √(x^2 + y^2+z^2) to add a force to a Rigidbody, which works marvelously, but I want to draw the orbit (using a series of point coordinates across the orbital path and joining them with a line renderer) so the player can accelerate/decelerate and see it adjust it in real-time. (and then just make the ship follow that orbit path because it would save a lot of processing power)

I have done loads of research and I can't seem to find a formula that will work without the semi-major axis or the total orbit time while explaining whats going on in an understanding manner. could one of you geniuses out there please help me out? I don't just want just the equation(i could just download a gravity plugin from the app store if I didn't want to learn), It would be nice to learn how it all fits together and how it works :)

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
1

Answer by Bunny83 · Sep 05, 2019 at 10:44 AM

Well determining the orbital parameters from the state vectors is not that trivial as the state vectors essentially just encode the derivative of the motion equation,


Though you probably can bring everythnig together piece by piece. You can determine the semi-major axis length from the orbital energy of the object


You can use the dot product to determine if you currently accelerate (moving closer to the central body) or if you decellerate (moving away from the central body). So you know on which side of the ellipse you are. Just do

 if (Vector3.Dot(velocity, vectorToCentralBody) > 0){
     // accelerate
 } else {
     // decellerate
 }

Maybe that will help you to get your equation finished ^^


Note while calculating the exact theoretical orbit certainly is helpful, it might not give you what your time discrete simulation is giving you in the end. This is due to being time discrete and having to deal with numerical imprecision which can accumulate over time. If you just want a relatively short prediction ahead, it's often simpler to just "fast forward" your simulation and see where you end up. This is the most accurate predition of what your simulation will actually do.

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 al-X · Sep 08, 2019 at 11:43 AM 0
Share

But shouldn't there be a way to calculate a future point with just state vectors? Like spaceflight simulator does? (once I have it in 2d it should be relatively easy to tilt its plain in the 3rd dimension) I literally just want to draw the orbital path/trajectory. And then I won't have to use the solution I'm currently using, rather, I just make the ship go towards the next point in the orbital path or trajectory. That way I wouldn't have to deal with impressions in my orbit prediction as such because in a sense the object would "follow its prediction"

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

187 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

Related Questions

Point gravity implementation lacks precision 2 Answers

How do you create a continuous physics simulation in Unity? 1 Answer

Can't Get gravity function to work 1 Answer

Orbit Sim without Physics Engine 1 Answer

How to lock an objects orbiting focal point. 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