02: Weekly Coding Suffering: Spawn Locations and NPCs
March 11, 2024
Welcome back to another week of suffering with code and art! Well not art yet, just code. Just. Coding. I want to do art 🙁
This Week’s Progress
This week, I focused on relearning Unity’s Scriptable Object Class. This class helps persistent data between sessions. And the best way to show my understanding of this topic was to code the player to spawn in specific locations when changing scenes! The player should spawn by the doorway and not in the middle of the room to simulate entering a room. Easier said than done.
To accomplish this, I created three scriptable objects to contain the player’s spawn location of the current scene, a level manager which allows us to assign the player’s new spawn location and switch scenes, and a player manager to find the spawn location and instantiate a player prefab at that location. I ran into so many errors because of naming issues and forgetting to label objects. So many errors… But, it eventually worked! With these objects coded in, it will also help us further down the line with maybe an inventory system and other triggers for puzzles. So that’s a positive!
I also added an NPC to test our dialogue and choices system, which was easier. This was also easily done with another script that could take in a boolean values to see if it’s a question or the end and a list of all the dialogue. I also added in the option trigger events that can allow us to use for puzzles and check if the player made a correct choice in speaking to NPCs.
Next Week
Next week is going to be hectic. Cindy and I talked, and we realized we needed a lot more function to our game than expected. I’ll be starting on actual art too! Our main character will finally be alive with an idle and walk animation.
Stay tuned to maybe see some artwork for the game if I figure out how to upload images!
Unity tutorials are my saving grace.
Leave a Reply
You must be logged in to post a comment.