I'm trying to write a plugin that will switch between the different SAS modes using the num keys. I already have that bit working, when I press a numkey the craft does indeed steer towards the desired vector and stays there. However the little GUI indicators next to the navball don't chage to reflect whatever mode SAS is currently on. It stays on the Stability Assist icon.
My code looks like this(it's probably not very good, this is the first time I try to code a KSP mod)
namespace AutoPilotKeys
{
[KSPAddon(KSPAddon.Startup.Flight, false)]
public class AutoPilotKeys : MonoBehaviour
{
void Update()
{
if (Input.GetKeyDown(KeyCode.Keypad7))
{
FlightGlobals.ActiveVessel.Autopilot.SetMode(VesselAutopilot.AutopilotMode.Prograde);
}
if (Input.GetKeyDown(KeyCode.Keypad9))
{
FlightGlobals.ActiveVessel.Autopilot.SetMode(VesselAutopilot.AutopilotMode.StabilityAssist);
}
if (Input.GetKeyDown(KeyCode.Keypad8))
{
FlightGlobals.ActiveVessel.Autopilot.SetMode(VesselAutopilot.AutopilotMode.Retrograde);
}
if (Input.GetKeyDown(KeyCode.Keypad4))
{
FlightGlobals.ActiveVessel.Autopilot.SetMode(VesselAutopilot.AutopilotMode.Normal);
}
if (Input.GetKeyDown(KeyCode.Keypad5))
{
FlightGlobals.ActiveVessel.Autopilot.SetMode(VesselAutopilot.AutopilotMode.Antinormal);
}
if (Input.GetKeyDown(KeyCode.Keypad1))
{
FlightGlobals.ActiveVessel.Autopilot.SetMode(VesselAutopilot.AutopilotMode.RadialIn);
}
if (Input.GetKeyDown(KeyCode.Keypad2))
{
FlightGlobals.ActiveVessel.Autopilot.SetMode(VesselAutopilot.AutopilotMode.RadialOut);
}
if (Input.GetKeyDown(KeyCode.Keypad6))
{
FlightGlobals.ActiveVessel.Autopilot.SetMode(VesselAutopilot.AutopilotMode.Target);
}
if (Input.GetKeyDown(KeyCode.Keypad3))
{
FlightGlobals.ActiveVessel.Autopilot.SetMode(VesselAutopilot.AutopilotMode.AntiTarget);
}
if (Input.GetKeyDown(KeyCode.Keypad0))
{
FlightGlobals.ActiveVessel.Autopilot.SetMode(VesselAutopilot.AutopilotMode.Maneuver);
}
}
}
}
I thought setting the autopilot mode would automatically make the indicator change to reflect the current mode, but apprently it doesn't. What am I missing?