FlightInputHandler

From Kerbal Space Program Wiki
Revision as of 21:58, 11 May 2012 by The Duck (talk | contribs) (Created page with "A class related to processing user flight control inputs. == Useful members == <table border="1"> <tr> <td><code>void SetNeutralControls()</code></td> <td>Sets all the contr...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A class related to processing user flight control inputs.

Useful members

</tr>

void SetNeutralControls() Sets all the control inputs to "neutral" values. This is particularly useful for setting the throttle to zero when you finish some autopilot function and want to return control to the user. You can't do this by just setting s.mainThrottle = 0 in your fly-by-wire callback (see below) because that just overrides the user's throttle setting, which may be nonzero, for one frame.
static FlightInputHandler.FlightInputCallback OnFlyByWire This lets you register a function to get called each physics frame that will be able to modify the flight inputs. An autopilot for example will want to do this. Usage:

FlightInputHandler.OnFlyByWire += new FlightInputHandler.FlightInputCallback(myFlyByWire);

where myFlyByWire is looks like

void myFlyByWire(FlightCtrlState s) { //code }

Within myFlyByWire you can modify the flight inputs by setting the fields of s. s will already contain the user's inputs for pitch, yaw, roll, etc., so you can leave them as-is, filter them, or override them completely, as you choose.

bool rcsLock Whether RCS is enabled; this bool corresponds to the "RCS" light near the navball that the user by default toggles with the "r" key.