Mobile Game Progression

Adding The Flame Sword

Simon Truong
3 min readFeb 19, 2022

--

One of the features that we need to implement is the one of the more expensive items within the game, the Flame sword. This ability allows the player to hit enemies and cause more dmg than the regular sword.

Preparing the Flame Sword Animation:

Thanks to GameDevHQ and filebase, we are provided with the flame sword animation asset, all we have to do is import and slice the image by 256 x 256 cell size. Then within our Player Animation window, we are going to create a new Animation and import all the sprites.

In the Animator window, we are going to create a new Trigger parameter called “Flame Sword Attack”. This will toggle the animation for the flame sword swing.

Toggling the Animation:

Thanks to our Game Manager, we already have an instance where we check whenever the player has obtain the Flame Sword. Since this instance can be triggered anytime at any moment it is easy to toggle the setting for flame sword activation.

Within the Game Manager script there is a public bool for Flame Sword.

In the Player Attack method we can basically add in a new if statement which checks for everything that the regular attack input is setup to check for, but the only difference is that the setting for Game Manager “Has Flame Sword” would be set to true. This creates a new result creating the ability to toggle the new flame animation instead of the regular swing.

You will have noticed that we are calling an method that does not exist yet for the player animation function. We have yet to create one for the flame sword swing. Head over to the player animation script and create a new method called “Flame Attack”.

Just like how we setup the regular attack sequence, we are going to do the same, but this time we are going to toggle the flame sword trigger instead of the regular attack trigger. The Arc swing is going to be set the same, but you can also swap it for a flaming arc if you have the asset.

Finally we have done everything involving the player and the player animation to play the flaming sword swing. All we have left is to create the ability to obtain the flame sword. We can achieve this with the MerchantNPC script which controls the store.

Within the Buy Item method where we have an array for different cases (such as obtaining the castle key or winged boots) we also have a case dedicated to the flame sword. Within the case array, we can basically call in the game manager instance, and set the bool for “has flame sword” to true.

Now whenever your player has the set amount of diamonds to purchase the flame sword, the game manager would know allowing the sequence of preset events to happen!

--

--

Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.