#18 | 2023-07-31 | Major Code Overhaul


Hello!

I've taken several days to rest and think about this overhaul. I will split it into different parts, starting with merging and rebuilding the player controllers. Next will be rebuilding the script that handles collision with triggers and changes various parts of the player controller.


In order to better organize what needed to be done, I created another section in my planner with much more detail than small changes and additions.


My previous system of changing how the player moves utilized four different player controller scripts that were toggled on and off by a master script on the player. While that worked, it wasn't very efficient in terms of number of scripts to manage.

To fix this, the new player controller contains four different functions that serve the same purpose of the preceding scripts.

A separate script, "TriggerDetection", will handle toggling these functions on and off via references to this script. The reasoning for this is to reduce clutter in this script.  Another script, "PlayerDeath" will handle killing the player with references to this script.

The core of this script is the various variables, mainly booleans, that are changed in relation to colliding with triggers. These booleans toggle functions and are referenced by other player prefab scripts.



To keep my script organized, I placed all the boolean checks (to check if a player controller is active) in a separate function and called it in Update.


Writing the movement functions was quite easy. I no longer have to copy tutorials for some things and I'm very proud of that. I'm getting better at writing code.

Unfortunately, implementing Rigidbody/Physics based movement proved to be too difficult; I could not figure out how to get my player to move how I wanted. It frustrated me to the point of almost dropping the project. I may come back to this in the future once I have more experience with Unity and C#.


At the bottom of the script there is the collision code. Quite simple, but allows the player to climb up a sloped tile which I had issues with in previous.

I've been working on this project on and off for two months. I hope that it'll be finished by the end of the next month so I can move onto some other ideas I want to experiment with, mainly RPG mechanics.


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.