Carrying on from last week, we were back to our solo games. Ant revisited the waypoint code for the guards for us to implement. Having covered this twice before I had my one lone scientist setup to patrol back and forth (to what would eventually be the locations of two computers) in a jiffy. I didn’t need to use an the more advanced waypoints script with the array for this simple first room however I’ll revisit that later in another level. I won’t post the whole guard script again as we have plenty of older posts covering this.
Originally the scientist sprite didn’t rotate, I had managed to code this into the player character using some code found online. I asked for some assistance from Ant to reverse enginner this to work for the scientist and it now works a treat.
We also needed a fail/game over condition added this week. The best place to start with this would be collision with the now mobile scientist/guard. Nobody is firing projectiles yet, or seeking the player so it seemed like the only reasonable fail condition for the first level. Using tags to identify the scientists an OnCollision2DEnter was setup within the player movement code to identify collisions.
Next on the agenda was exiting the level which took a few steps. I wanted a keycard to be collected before exit was allowed and hope to retain these cards to open up colour coded doors in future levels. This takes us right back to the beginning of the year when setting up the key/door in our first Unity project. On top of this I also added an inventory list to store the item, the same as my walking simulator.
The collision detection to exit the level with key in hand was also added to the player controller script. I won’t repost all of the inventory scripts as again they have been covered before in older posts.
Having gotten to the optional part of my checklist I attempted to make a particle system that identifies to the player a key has been picked up. I had spare time in class and decided to tinker.
I’m not super happy with it and need to tinker with it further to make it far more subtle, and also need to gain the knowledge of how to call upon it. Things to do, things to do! Be back next week for another update!