Hello and Happy Aloha Friday! Here is a recap of today, Day 46 of my 60 day challenge to become a Unity Game Developer!
Take a look at my progress:
I spent a lot of the first half of the day in meetings and working with my teammate to debug some small issues with our weapon systems as well as the weapons themselves. One thing that took a minute to figure out was that with certain weapon prefabs soon after the object instantiated it was getting destroyed. It turned out that from within the OnTriggerEnter() the destroy method meant for the powerups was being called just outside of the if statement checking for the powerup tag, since the weapons also have colliders, it was destroying the weapons a frame or so after it instantiated. We moved it to where it needed to go and all was well!
I also realized that I kept getting an invalid id error once I collected more powerups than was needed to change the weapons out. Just as a recap, the intended behavior is that every time a powerup is collected, the player’s weapon gets incrementally better and better. This works by increasing an int (weapon power up id) by 1 every time a power up is collected, which then calls to a case that sets the weapon based on an int which references a sepcific weapons enum (int) which calls to different indexes in a weapon array…. a mouthful I know. If that doesn’t make sense I dropped a screenshot below. To solve the invalid id issue I added in an if statement to only increment the weapon powerup id if it was less than the number of items in the array. Also, cleaned up the if statements in the fire method to a switch statement (big thanks to our awesome lead for the tip!).
Here is what the code looks like now:
I spent much of the afternoon researching and starting to create a new weapon! This is the last weapon you see instantiate in the gif above.
Here is how I approached this:
I knew that I wanted to use a particle system somehow so first thing I did was attached it to a prefab. By childing it to the object it ensure that the positioning is always right where I want it to be. Then I messed around with the particle settings until I got something that I was feeling pretty good about.
After that I realized that I needed to add a bit longer between instantiations than the other weapons so similar to the general fire rate set, I created another one just for this weapon.
We as a team decided that we’d like the player to have more control over when and how they fire so we are actually going to remove the automatic firing behavior so it is possible that this will change. I also plan to create some logic so that the weapon moves in a more interesting way . I think I want to try to do that through a mix of code and animation. If I end up doing a lot of it through code, I’ll probably create either a separate method or script and call if that from within the case instead of hardcoding the logic in there. This will likely be true for the other weapons my teammate is creating as well.
Other things that happened today:
- Awesome animations presentation from Al at GameDevHQ! Watching how the pros do it is always super informative and helpful. I know I’ll definitely be using what I learned today when I start to get into the animations for the weapons I’ll be creating. Here is a snapshot that I creepily took earlier for the purpose of this blog.
- Lots of git practice!
- Honestly no serious challenges today.
This weekend I will either take a break and try to do a little work on my 2.5d game that I started earlier this week or may work on more weapons behavior. Either way, I’ll be sure to post about it here :-).
Have a good evening.