Jump to content

Nelluq

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Nelluq

  1. I made an account to post this because I've used up all my debugging ability and can't for the life of me figure out what's going on. I'm writing a mod that needs to get data from the vessel and control it. This is all being done from a PartModule subclass: class Controller : PartModule { public bool Running { get; private set; } public override void OnStartFinished(StartState state) { if (state != StartState.Editor) { vessel.OnAutopilotUpdate += FlyByWireHandler; // also tried with vessel.OnFlyByWire, same result } } public override void OnFixedUpdate() { Debug.Log("OnFixedUpdate Running="+Running); if (Running) { // get data from the vessel } } private void FlyByWireHandler(FlightCtrlState state) { Debug.Log("FlyByWireHandler Running="+Running); if (Running) { // control vessel } } public void Start() { Running = true; } public void Stop() { Running = false; } } There's normally some other stuff in there too, but I've gone so far as to strip it back to just this and the problem still happens. As expected, both OnFixedUpdate and FlyByWireHandler get called on every physics update, and dump logs to the debug console. After Start() has been run (it gets called by a separate UI object), the logs from OnFixedUpdate() turn into "OnFixedUpdate Running=True", as expected, but the logs from FlyByWireHandler() remain as "FlyByWireHandler Running=False", and no code within the if statement runs. I've been stuck here for 2 whole days, and I just can't figure out why the same property would be read as true by one method and false by another. I've tried making Running a public field (public bool Running; instead of public bool Running {get; private set}), and that doesn't change anything (not that I expected it to). Does anyone know why this might be happening, or at least anything else I can try to narrow down the issue? This behavior makes absolutely no sense to me.
×
×
  • Create New...