Automation for the win


Author: Aaron King


As the weeks are winding down there isn't much left to add features-wise, so I've been going back in a fixing small bugs for the most part. But there was one recurring issue we kept having every week and I would put up a hotfix for it and ignore the bigger problem at hand. And that was the way the cheat manager was handling any cheat that required the player to move to a new scene via some other method than the 'doors'. Since the same player object is used from the time the game boots up until you exit the game, just loading the scene wasn't possible as the character would not be positioned in the correct location as the scene was loaded. Being that there are over 105 rooms the player can go to, hard coding the default location for each of them would have been tedious and prone to causing even more issues down the line. (not to mention really ugly)


I instead opted to look into something that would automate that process and store that data inside a scriptable object that could then be referenced when the players' location was changing to make sure they got moved to the correct location in the new scene. That made it possible to get the players' location in every scene in under 10 seconds without needing to copy and paste over and over again. I just created a custom editor button on the scriptable object that calls for the editor to open each scene one at a time and find the player in each scene, and once it finds the player it will save the name of the scene and the transform location of player into a struct that can then be used by the cheat system to move the little guy into position. About 50 lines of code saved me hours of mundane work.

Files

WebGL.zip Play in browser
Dec 01, 2022

Leave a comment

Log in with itch.io to leave a comment.