Jump to content

How to detect change in orbit?


Recommended Posts

6 hours ago, Xyphos said:

I'm working on a partmodule and I want it to detect when the vessel's orbit changes

eg, Ap/Pe modified, inclination changed, and SOI changed

not sure how to implement such a thing

If you are looking for an event-driven architecture... start with the GameEvents class and see what it offers.  Might well be an easy event you can subscribe to, that will call an event-handler/callback whenever the orbit changes.

If you are looking for a polling-driven architecture -- simply cache the current values into your partmodule, and examine the values from the vessel every frame/update.  When they no longer match, you know the orbit has changed.  There are 6 or 7 parameters you'll need to cache, as every one is used to determine the unique orbit: https://en.wikipedia.org/wiki/Orbital_elements

(might be named slightly different in KSP)

Edited by Shadowmage
Link to comment
Share on other sites

  • 1 month later...

That's gonna be hard, since while the vessel is off-rails it basically constantly changes its orbit. The "orbit" itself is just a prediction, which is strictly followed only when the vessel is on-rails. As soon as physics kicks in - all bets are off where exactly the vessel will fly.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...