Hi,
It does look like a glitch in your logic or setup, loading scene is tricky however because component life cycle is messy during that transition.
If you can isolate this in a project, with just PlayMaker and two scenes with this, I'll have a look and submit a but report if I can repro and locate that it's indeed an issue with PlayMaker.
Bye,
Jean
So I decided to do just that (create a new project) and the variable did keep it's value when I returned to the original scene. I went back to my original project and decided to start removing other objects from the scene to locate what was causing it. There were other FSMs in the scene when I first tested this, but I deactivated them, so the only things that were activated was the Player, the floor, and the trigger object that initiates the scene change (it's the player by the way that's setting itself as a global variable).
I ended up isolating the issue to an FSM on a different object. It sets the player to the correct position in the scene using Set Position just when the scene loads up (the object that has this FSM is loaded with the scene). If I remove the state that contains Set Position (which sets the position of the Player gameobject global variable), the global variable does not go null.
There is another case of a different gameobject global variable going null. This time it's fixed when I delete a state from an FSM that contains a Send Event with the target being the object that set itself as a global variable.
Even if I deactivate the objects that cause the problem, it doesn't fix the issue. They need to flat out not be in the Hierarchy.
So basically...
- My global variables keep going null if I return to the scene where these variables were originally set.
- This occurs because other objects in the original scene reference it (this doesn't occur on the first time in the scene, or in any other loaded scene, even if the objects that cause the issue in the original scene have instances in subsequently loaded scenes). This is only a problem on a return visit to the original scene.
- It doesn't matter if the other FSMs that cause the issue are deactivated or not. They must not be in the scene for the variable to not go null.
It's... really strange.