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
0
Question by wonkyCircumflex · Sep 17, 2019 at 07:54 AM · physicsorbitgeometrytrajectoryspaceflight

Ellipticall Orbit like Spaceflight simulator

I'm making a game relying on 2D rockets that orbit planets and shoot each other. I would like to be able to predict and draw the rockets trajectory from the positions of the planets, the velocity and mass(within a sphere of influence) like in spaceflight simulator. it doesn't need to be exact, but a closed loop when it comes to the elliptical shape would be nice, so I'm guessing this is more geometry that physics. I have looked everywhere and can't find a simple, strait-forward formula. And I'm sure it's out there because so many simulators predict orbits from current state vectors. I'm not a physics or algebra wizz, but I am always happy to learn(so an explanation would be awesome if possible). Could someone help me out? or just provide me with a formula and ill try my best to figure it out.

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 Pangamini · Sep 17, 2019 at 08:01 AM 0
Share

Well, if you have multiple planets (bodies) affecting the spacecraft, it will not be a closed loop.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Pangamini · Sep 17, 2019 at 08:08 AM

Well, if you have multiple planets (bodies) affecting the spacecraft, it will not be a closed loop. If you want to get something like kerbal space program, then you should know that kerbal is simplifying gravity in a way that the spacecraft is affected by a single body (moon, planet, sun) and its whole simulation frame moves with that body, so you get perfect elliptical orbits. The way Orbiter does it (a really cool spaceflight simulator btw) is that they predict an elliptical orbit, but it gets gradually affected by the other bodies. So even if you see an ellipse drawn, it might be changing over time (even within a single orbital period) in complicated multi-body systems, such as Jovian.

One way is to calculate the elliptical orbital function using the kepler laws.link text. While those may sound simple, the mathematical implementation is quite tricky, and as I remember, the one I used was only iterative approximation anyway (I didn't come up with it, found it online). The other way would be to actually simulate your universe ahead of time and sample the predicted rocket trajectory. For that, you might want to have some kind of copy of your universe (ideally if you can separate it from the monobehaviours / unity physics) so you can create a copy of the physical universe, fast-forward it some time, read the trajectory and ditch it (so your actual game state stays unaffected)

Comment
Add comment · Show 3 · 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 wonkyCircumflex · Sep 17, 2019 at 08:53 AM 0
Share

Thanks for your answer! and yes in my simulator/game gravity will only affect a rocket within a certain radius so, making it only affected my one planet at a time. How did you implement the $$anonymous$$epler laws in an iterative approximation way? (I'm just looking at the $$anonymous$$epler laws, and as you say, the implementation seems quite daunting ), The copy of the physical universe method seems good, but then I still need the formulas, and I don't know where to start with those. what I really want is something like this

avatar image Pangamini wonkyCircumflex · Sep 17, 2019 at 09:14 AM 0
Share

will only affect a rocket within a certain radius so, making it only affected my one planet at a time

the statement above is not necessarily true, you might still have overlapping influences Also, your spacecraft may leave one circle of influence and enter the other as it moves. Again it won't give you a closed loop trajectory. Real world gravity has infinite range, so if you are interested in implementing kepler laws, keep that in $$anonymous$$d
avatar image wonkyCircumflex Pangamini · Sep 17, 2019 at 10:37 AM 0
Share

ok, so it does not always have to be close looped, I just wanted to make sure that when it was a normal elliptical orbit, the formula would not create slight imprecisions so that the two endpoints would meet. but yeah, I definitely understand the hole in my logic now(i was thinking of one planet, and thought i could just "make it work" with the others). There is a workaround though, I can stop predicting the outer trajectory once it's in the sphere of influence of another body, as in "rendering trajectory from the earth, and if it hits the moon's sphere of influence, stop rendering" and when you(the rocket) are in the moon's influence, do the same but relative to the moon. But then i need to predict where the moon is, so thinking a little deeper about what you said regarding having a hard copy of the physical solar system, it's definitely the best way because I can also predict the interception of the rocket with planets during its its course. But how would I go about doing that? thanks so much for your help so far!

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

185 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

Related Questions

Problem with a ballistic trajectory simulation (rigidbody.velocity) 0 Answers

Bounce not always triggering 0 Answers

Using the UnityEngine.Plane struct, what's the best way to check if a collider is crossing said plane? 0 Answers

AI Turret Aiming 2 Answers

plotting a line which shows a spaceships course 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