Forum rules - please read before posting.

AC doesn't save after OnBeforeChangeScene


So, I have a function that subscribes to OnBeforeChangeScene. It's supposed to save off a few variables just before the scene switches to preserve the state of the scene. However, my changes never persist when the scene loads back in. Looking at the SceneChanger.ChangeScene method, PrepareSceneForExit (which I assume saves the scene) gets called before Call_OnBeforeSaveScene. Is this behavior intended? Would it be possible to call the event before saving the scene?



  • What variables are you looking to preserve?

    The intended way to save custom data about a scene is to rely on a custom Remember component - this tutorial has details.

  • I'm using custom Remember components elsewhere in my project, but I don't think that'll work for this case.

    Our game has a terminal where the player can receive messages. I'm trying to save which groups of messages have been unlocked so far and which have been read. I'm using a local variable because I want to be able to easily edit the state for testing.

    I know I could set it up to be able to edit the state with a Remember component, but there are other local variables I'd like to be able to edit. It would be nice to have all that relevant information in a single place, and the local variable window seems like it's set up perfectly for that.

    I actually tested the fix I suggested. The variables get saved off just by switching the order of two lines of code.

  • It's a simple change, but it could have unintended consequences elsewhere. I will look into it.

    To clarify: the fundamental issue is that you want to update a Local variable's value before the scene-change?

  • Yes, that's correct. And I know there could be side effects. That's why I asked if there was a reason it was set up that way in the first place. Thanks for looking into it.

  • The lines will be switched in the next update.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.