10/26/2025
Sprint 4 Kickoff
For this sprint I had one huge focus that I needed to accomplish. Essentially it was to convert all of our old movement system to Unity’s new input system. At the start I had underestimated how much time this would actually end up taking me since I just thought it would be a simple change, but it ended up being more difficult than I thought. The problem was I was trying to quickly convert all of our old movement functions to now work through the new input system directly without first considering that the whole movement functions would need to be reworked.
For example, the old way of moving right and left was through directly telling my players transform.position to now move either left or right and the new input system does not seem to like that. Another big contributor to the problem was the fact that I did not stop and test my code every couple minutes like I should have been. Instead, I tried to rewrite and try to match everything with the new input system and then run my code. Long story short, I ended up getting all 3 of my main old movement functions (Move, Jump & Dash) to finally work in the end, but it would have been done a lot sooner and easier if I had been more patient with it.
Alongside this entire mess I was also trying to productively clean up and decouple a lot of my old code in order to get it to look much more professional and cleaner. This was important to do since my old script basically had a lot of moving parts all tied together. Essentially, I had all of the 3-movement mechanics, the collision detection as well as the glowing functions all in 1 script totaling over 400 lines of code. This was definitely an inefficient way of doing things since I would constantly need to go back to this script and alter or check the code for testing and debugging.
What I did for this was separate the players mechanics from the collision events into their own scripts that would tie directly back to my player prefab. Inside those scripts I also made headers for all the variables that could basically be considered in the same group. I set a bunch of those variables to private as well since I would not need to edit them inside the inspector window and would clear up a lot of space for the ones I did need. To summarize my player prefab would now have 2 scripts attached, one for all the player inputs/mechanics and one for all the collision tracking. This would now make it 10 times easier to go and update something in the code if I needed to in the future based on the thing I am trying to add.
By the end of this sprint, I was also given some tasks to work on implementing a key and door system. So, what I did for this was create 2 simple prefabs in the meantime of a key and one of a door. As soon as I did that, I gave them colliders, and I was able to get them to play animations that I made inside the Editor. For the keys animation I made it so that it could be a looped animation that basically looks like the key is spinning and floating in space while the door was just a simple change in y position. Then I moved on to throwing the animation of the door into Unity’s Animator so that it could be listed as a clip. I would then play that clip through code whenever my player has collected a key and has collided with the door. This was simple enough to do after all my movement and code was polished up so I'm glad I was able to accomplish a lot this sprint.


No comments:
Post a Comment