2D Mobile Game: Flame Sword Upgrade

Ryan McCoach
3 min readJun 6, 2022

Intro

In this article, we cover how to upgrade a weapon that can deal out more damage. In my game, the player needs to purchase the upgrade weapon.

Game Manager

The Game Manager script is in charge of giving the player what they purchased from the shop.

This is done using boolean variables to track if the player has or has not purchased the upgrade.

If the player has enough gems to purchase the Flame Sword, the bool is set to true.

Fire Sword Animation

The player has an animation script that handles all of the animations. We will need to create a fire sword swing animation and be able to transition to it using a trigger called FireAttack.

In the player animation, we create a public method to be called when we attack and have the Fire Sword Animation to play using the trigger.

Attack & Damage

In the Player script, when the player uses the attack button we need to check if the player has acquire the flame sword . If so, the Fire Attack animation is called and if not, the normal attack animation is called.

In the Damage script for the enemies, we again check to see if the Player has acquired the Flame Sword. If so, when the enemy takes damage they will lose 5 health and if not, they will only lose 1 health.

This logic relies on a Game Manager Singleton, which I cover in a previous article below. The Game Manager Singleton is a great way to enable power ups or upgrades your player has earned from one spot instead of several scripts having to communicate.

Game Manager: https://ryanjmccoach.medium.com/2d-mobile-game-shop-ui-buying-items-b541cb33483b

Until next time…Cheers!

--

--