I've searched the forums and couldn't find an answer, there is probably an easy/obvious one I am missing.
I use the singleton manager to prevent duplicates on my controllers as the game moves through different scenes (I have dups so that the game can be run from any scene without having to start at the title screen). This works fine.
The problem arises in that I have these controllers define themselves (get self) and store as global game object variables so that other FSM's can access them.
On scene load, the singleton manager destroys the original game object, which causes the controller to lose its global var game object assignment. So I add an action for the controller to re-define itself after any level load.
This doesn't work well, it requires a loop as the self-definition fails silently as the first step after level load. So I have to check if it is null and loop (get self) until it gets defined. This works, but causes a cascade of timing issues, as I can't rely on that controller being defined in the first few frames after load. I am also concerned that the timing is not deterministic and could vary per user so it may cause some hard to track bugs in the wild.
If the singleton manager resolved duplicates by destroying the object in the NEW scene- instead of the one that is already in use, I think it would avoid all of these problems and my global variable game objects would stay defined.
Maybe there is another pattern I should be using. Any help appreciated!
Thanks!