Jump to content

Questions About Asteroids (and the Orbit Class)


Recommended Posts

I'm trying to find which Asteroid are on a collision course for Kerbin and I can't seem to get the info from the orbit Class.

Vessel.orbit.closestEncounterLevel always seems to be None for not active vessel;

Similar results for (all return false, none, null, etc...) :

  • orbit.closestEncounterBody
  • orbit.closestEncounterPatch
  • orbit.nextPatch

The only information I need is the altitude at periapsis around Kerbin, if there is one. (Then set to Asteroid to be auto-tracked, Which I know how to do thanks to http://forum.kerbalspaceprogram.com/threads/75376-Asteroid-Spawn-API )

But so far, if the vessel is OnRail (AKA not the active one), I cannot get any orbit information besides the current orbit. (and I can't get Orbit.SolveClosestApproach to work)

Any idea?

Link to comment
Share on other sites

To reply to my own post, This is code that made Patches possible.

if (!v.PatchedConicsAttached) {
print("No PatchedConicSolver. Creating a New One. ");
v.patchedConicSolver = new PatchedConicSolver ();
v.AttachPatchedConicsSolver ();
v.patchedConicSolver.Update ();
}

I still have to figure out why it works Sometimes, and sometimes, it gives my a NullReference Exception for AttachPatchedConicsSolver ()...

But at least now I have Encouters and NextPatch in the robit of each vessel (just need to remember to run v.DetachPatchedConicsSolver () once I have the info I need....)

Link to comment
Share on other sites

These are exactly the 2 questions I came to this sub-forum to ask.

However I can't see on the linked thread anything about making an asteroid tracked. I want to start tracking an asteroid at the moment that the player accepts a contract involving it. At the moment I have the regretable situation that a player can accept a contract only to find that the asteroid involved gets deleted immediatly afterwards.

edit:

Found this discovery line

vessel.DiscoveryInfo.SetLevel(DiscoveryLevels.StateVectors | DiscoveryLevels.Name | DiscoveryLevels.Presence);

Will this be enough to prevent it from being deleted?

Edited by tomf
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...