#19 | 2023-08-01 | Major Code Overhaul


Hello!


It's time to work on the next part of the player code overhaul. With music playing and soda in hand, I am motivated to work.


Setting up this script is very straight forward. I've become very familiar with referencing game objects and their components, which is crucial part to making bigger and more complex systems.


I followed this table to determine what each trigger does. Although it is almost two months old, it's still relevant because I haven't added any additional toggleable functions. I may do that later though, we'll see.


I've written the same or similar code over and over again, so I've learnt what it does and how to use it. I'm very proud of my work.


With the trigger detection script set up, the next task was to rebuild the script that handles player death. Picture below is the rough outline of the script.

Coroutines are very useful for only calling a function once, provided that you do not loop the coroutine. I love using them for various things.

When the player collides with  a trap (saw or machine press), a particle effect is spawned (explosion of pixelated blood) and the player prefab is destroyed.

When the player collides with acid, there is a delay before destroying the player prefab to allow the player to sink into the acid before killing them. To make this happen, I had to tweak the PlayerController script a bit.

When the player collides with acid, the player's gravity scale is changed to a small scale to make it look like the player is slowly sinking into the acid. I'll probably use this for other liquids like molten steel or water, if I add them to the game.


With the main player scripts complete, I will completely rebuild the Game Manager scripts "SetPlayerVariables" and "RespawnManager". It's confusing to try and change aspects of them  so I think it's best to do a full rebuild.

One more thing to mention: Having good version control is incredibly important. I backup my project before every big change incase I need to revert back because of a catastrophic error.


Thanks for reading and stay tuned for the next log!

Get Factory of the Damned

Leave a comment

Log in with itch.io to leave a comment.