25/8/22 - Level Switching & Loading


Today has been PAIN.

Level Changing

It began good with me making the portal thing to switch to the next level which is just a spinning sprite with some lighting that has a trigger. The level switching it self just got worse and worse. It first didn't like unloading scenes (i was trying to load the levels additively) because it could get the precious level so I spent an hour fixing this. I then was trying to get the transitions to set up and it would just break everything in the async operation because why not. Also the lighting would just break when the scene changes and all the lighting from previous levels would not be unloaded. I eventually just went to loading the level in a singular fashion rather then additive which was less problematic after tweaking.


Saving

To save the players progress I would just saving all the cubes positions and states, along with the active cube and the level to a json file. This was pretty easy expect for the fact unit's inhouse json serializer wont serialize lists of custom classes so I had to switch to the one from newtonsoft. After I got loading and saving working I realized that switching between cubes when the cube your are trying to switch to isn't present in this level is broken. I spent like 2 hours trying to fix this and almost every fix would just cause a stack overflow. I ended up completely rewriting the player manager, game manager and the switching function so that it would check if the object was active in the level and if it wasn't then switch to the closest active one.



Get Cubemunity - Brackeys Game Jam 2022.2

Leave a comment

Log in with itch.io to leave a comment.