Jump to content

FlightGlobals.Vessels has more than just vessels


Recommended Posts

I've come across a problem where the following code gets a lot more than the existing vessels:

            foreach (Vessel vessel in FlightGlobals.Vessels)

A number of the vessels returned are actually null, and apparently asteroids are also considered to be vessels.  Also, some not-null vessels returned don't seem to have a rootPart (it's null).

So is there an easy way to determine if a vessel returned from the list is a valid vessel?

I will point out that in my testing, there is only 1 vessel, yet this list has 8 or more entries.

I am looking at the vesselType, which seems to be helpful.  Is there any other way? 

Edited by linuxgurugamer
Link to comment
Share on other sites

26 minutes ago, linuxgurugamer said:

Is there any other way? 

vessel.state ?

vessel.protoVessel.*** (lots of info here)

Parts and root part may be null/empty if the vessel is not loaded, protovessel should contain data.

30 minutes ago, linuxgurugamer said:

A number of the vessels returned are actually null,

Unity overloads the equals operator, and returns a fake null for deleted game objects..

Link to comment
Share on other sites

17 hours ago, Shadowmage said:

vessel.state ?

vessel.protoVessel.*** (lots of info here)

Parts and root part may be null/empty if the vessel is not loaded, protovessel should contain data.

Unity overloads the equals operator, and returns a fake null for deleted game objects..

Thanks, this will be very helpful

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...