Difference between revisions of "FlightInputHandler"
From Kerbal Space Program Wiki
(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...") |
|||
Line 1: | Line 1: | ||
− | A class related to processing user flight control inputs. | + | A class related to processing user flight control inputs. In particular it lets you register a function to be called once per physics frame that can modify the flight control inputs. |
== Useful members == | == Useful members == | ||
Line 21: | Line 21: | ||
</td> | </td> | ||
</tr> | </tr> | ||
+ | <tr> | ||
<td><code>bool rcsLock</code></td> | <td><code>bool rcsLock</code></td> | ||
<td>Whether RCS is enabled; this bool corresponds to the "RCS" light near the navball that the user by default toggles with the "r" key.</td> | <td>Whether RCS is enabled; this bool corresponds to the "RCS" light near the navball that the user by default toggles with the "r" key.</td> | ||
</tr> | </tr> | ||
</table> | </table> |
Revision as of 22:00, 11 May 2012
A class related to processing user flight control inputs. In particular it lets you register a function to be called once per physics frame that can modify the flight control inputs.
Useful members
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. |