Week 5: 'Trash Mobs'
March 29, 2024
Hello, and welcome to week 5 in our operation of designing Themedior! At the top of today’s agenda is a Q & A. Then, I will be discussing implementing our main character’s attack/projectile system, health bar, and scene changes. Finally, to finish things off, I will talk about enemy creation.
Q&A
Q: “When you say that the animator treats animations as a node, does “animations” refer to parts of a whole animation, or separate complete animations that transition into each other?”
A: For the animations in Unity, I created separate complete animations (refer to the gifs of jumping, walking, running, and attacking) and each of these animations would be treated as a node in the animator. In the animator I can set a default animation that plays on start and then transition to different animations using triggers and parameters. Essentially, the animator is a tree consisting of animation nodes.
Q: “Are PSD and PSB files just file types for animations specifically?”
A: PSD and PSB files are not just used for animations. PSD/PSB files are also used in digital art and digital design as they often require the use of multiple layers.
‘The Attack Begins’
For our main character’s attacks, he will be shooting bullets out of his gun. Creating the bullet sprite and scripting it to instantiate on a mouse click and move was easy but getting the bullet to appear like it was coming out of the gun was a lot harder.
Initially, I tried adding a Rigidbody component to the gun and getting that component in the parent script. However, this didn’t work as the rigidbody resulted in the gun not moving with the player anymore. After tinkering around for a bit and with the help of google, I was able to get the bullet to start at the gun position using “GameObject.find(“gun”).transform.position”. This looks in our parent game object for a child game object called “gun” and finds the child object’s position using “transform.position”.
Getting the bullet to spawn at the gun’s location was only the first step of the challenge; I also needed to delay the bullet’s spawn time to match the animation. To do this, I changed my method from void to IEnumerator. This enables me to use a coroutine to trigger a wait time.
Finally, so that the bullets don’t destroy themselves when coming into contact with the player, I placed the player sprite and bullet sprite into separate layers and configured these layers in the settings to not interact.
Change in Scenery
Another thing I accomplished this week was creating a UI and a scene manager. The UI only contains the health bar for now but I’ll eventually implement a pause button. The health bar contains its own script for decreasing based on player health and it currently looks like this.
The scene manager essentially just contains methods that change scenes. I then add this script to an empty game object and link this game object to buttons and select the function that I want to execute on button click.
‘Invincible’
As of this week, I have created the basic enemy movements, but haven’t implemented a health system for the enemy, so the enemy is currently invincible. Additionally, The enemy can’t initiate attacks yet, so the player is also technically invincible. I will probably implement the damage system next week, so the player and the enemy will no longer be invincible.
here is what it currently looks like.
Week End
That concludes my progress for this week. Next week, I will be moving onto finishing the damage system and starting on the dialogue system. Additionally, I plan to add gravity so that our main character can finally jump. See you next time.
Reader Interactions
Comments
Leave a Reply
You must be logged in to post a comment.
Cindy L. says
It’s nice seeing the little touches, like how the enemy recoils slightly when hit by the bullet. I also really like the HP bar design, since its glitched-out look is rather unique and interesting. Best of luck with implementing the damage and dialogue systems next week!
Isabelle E. says
I love the animation!! The UI looks good too! I recommend using Ink from Inkle for dialogue. It uses a different coding language but it’s easy to understand and organize.