Flaming Sword Power Up!
Objective: Create the flaming sword power up for the player to purchase from the shop!
In this tutorial we are going to make another power up for the player to purchase from the shop. This power up is going to be a new attack. Setting this up is similar to how we’ve created the original attack.
We begin by slicing a sprite and creating an animation with your new attack.
From here take these sprites and create an animation.
Remember, even though we may have different sprites, the process is the still the same. We need to make a new hitbox for this new attack. create an empty object under the players sprite and add a rigidbody and box collider.
The process of creating a hitbox may not be quick, but it will give you an accurate representation of hit detection. Select the edit collider button and shape the collider to cover your weapon for each frame.
With the hitbox complete we can now navigate to the animator view and connect this new animation to your animation tree. For mine, the connections will be similar to the original attack, so I have a transition to and from idle as well as run.
We will need a new bool parameter for the new attack.
For the transition to the original attack, we need to add the condition, “Fire Attack = false”
For the new attack we need the condition, “Attack triggered” and “Fire Attack = true” The has exit time is false and the transition duration set to 0.
The transitions back will have their respective move conditions, the transition duration set to 0 and has exit time set to true.
You can toggle the bool parameter in the edit to test if the new attack works how you want it to. Once you are satisfied it’s time to code. Let’s begin with the player’s script.
We need a variable to represent the flame attack powerup.
We need a method for the shop to call and turn this bool true.
If we look at how are player currently handles the attack function. When the player presses the A button the player calls the player animation script. We’ll need a new one. We need a method to call to set the animation parameter true.
Again, at this point we can save our progress and test this in the editor. Turn the Fire Attack on the player to true and pressing the A button should set the animation bool to true.
After a successful test it is time to head to the shop keeper script. When the player purchases the Flame Sword, the shop keeper will call the player’s script to activate the flame sword powerup.
We are done. Now you can activate the flame sword power up. In the next tutorial I will show you how to make your attack script and the IDamageable more modular and make the flame sword more powerful of a weapon! I’ll see you in the next tutorial!