Jump to content

RESOLVED: Q: How do I get the current vessel from a KSPAddon FixedUpdate method.


Recommended Posts

TL:DR  :  Q: How do I get a Vessel object for the current vessel, when not in a part module

I'm trying to write a plugin for remotetech that will after a delayed time ( 1 - 2 hours), will start cycling the longest range transmitter through different targets to try to find a connection if there isn't one available.

Scenario.

 My duna network just went out of range of kerbin,  but there is a possible connection available via another satelite in a sun orbit. I want to have the probe start cycling possible connections until it finds a valid connection.

In the future, this would be done via an interface while still in kerbin orbit, ie. 

  • Kerbin  - Mission Control
  • Comms Sat 1 - 6
  • Sun Sat 1 - 6
  • Jool comms 1 - 6

etc.

Thanks

GE

 

Edited by genericeventhandler
Link to comment
Share on other sites

FlightGlobals.ActiveVessel is the players current vessel

PS

This doesn't sound like it needs to be in FixedUpdate, therefore you should be using Update (if it doesn't affect physics, avoid FixedUpdate)

Edited by Crzyrndm
Link to comment
Share on other sites

As far as I'm aware, the FlightGlobals class should always be available. (taking a guess here, but do RemoteTech addons also derive from MonoBehaviour?)

So you should be able to just do something like

Vessel ActiveVessel = FlightGlobals.ActiveVessel;

If that's not working, I can only suggest asking in the RemoteTech forum. They'll know much more about how their addons are supposed to work.

EDIT: jinxed by @Crzyrndm :)

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