Monday, April 2, 2018

Game Jam! - Get me out of here!

The week before spring break we had a game jam, and the theme was 'Get me out of here!' An interesting topic, to say the least. Our team took a take on the classic Prison Escape genre. Except instead of figuring it out yourself, you are hinted on how you should escape via text boxes.

I had to adapt to several new ways of coding that I have not tried before in order to get the result that the game designers wanted. This included learning how to use major UI in the game in order to give off the text box, interact button, and more. I also had to adapt to intractable events and how to get them to work.

Below is the code for the player script. It is ugly. You have been warned.

I guess the best place to start is the player Start in the player script. This is finding the animator and rigid body which are both used later in the script. It is also setting the narrator name to Narrator.










The next lines of code are used to spawn the player in the next level's spawn position. It finds any gameobject in the world with the name spawn, gets it's transform. and moves the player to the spawn's position. It also resets the interact and caught variables.

The code above is used to solve an issue the game was having. Basically, if you were caught it reloaded the first level. It would then duplicate the player do to the DontDestroyOnLoad function. So this prevents that from happening with a simple bool.

I am not proud of this code, but it gets the job done. Basically instead of setting up a simple base for every intractable object I wrote an if statement. For. Every. Single. Thing. Yikes.



This is where is starts to get ugly. In order to save time because it was a game jam, I skipped setting up any base code for anything. I also didn't set up Axis controllers or a good movement script. I set it up so you could only use WASD. and E for interact.




The player script also had an if for every collision. Yikes. I could have solved this by using a case or switch function.


I also made a quick image fade for scene transitions.