Triggers and Scene Transitions


CATnapped's two main puzzles both are situated on separate scenes away from the main scene. This was mainly done to avoid relying on the use of a canvas too heavily, but also so that certain game objects wouldn't need to be present during the entire runtime (e.g. the pipes, furniture). However this causes some problems such as remembering player position, keep track of inventory data and keeping track of which items have been collected.

As mentioned in the Pipe Puzzle devlog, these objects were given the DontDestroyOnLoad property so when these new scenes were loaded we wouldn't lose necessary game data (i.e. inventory items, player position). This worked quite well however this then caused other issues, certain triggers would require an object that doesn't get destroy, if this was the case and a new scene was loaded, the trigger would be unhooked from that object making that trigger not work properly. Knowing it would be out of my own league to create a workable save function to store the required data and load it when back in the house scene, most objects in the house actually remain loaded whenever you enter the tidy puzzle or the pipe puzzle, though none of these objects (such as the player and item spawners) can ever intervene with the puzzle as they are moved away from 0,0 to prevent this.

Also, using this system for keeping track of things, I learned that DontDestoryOnLoad requires the game objects that have the script to be active within the scene, otherwise it wouldn't work, which required me to use an extra layer of code where these game objects remained active in the scene, however when the scene would be activated it would find the game object and turn it off using the Awake() function.

- Noah O'Brien

Leave a comment

Log in with itch.io to leave a comment.