Log 05: Consumable Items
- Kassandra McCormack
- Oct 7, 2023
- 3 min read
Consumable items have less to do with the Sentai theme, and more to do with being a Warriors style game. Older Warriors games often had items that you could pick up during a level and have the effect immediately applied. Things like attack or defense increases, health restoration, or even increased exp gain. More modern Warriors games have items that you chose when to use based on button presses. Specifically Hyrule Warriors comes to mind, although other than healing, the other items are different elemental damage. So for my game I decided to implement the older type of items, but with the new control scheme.
The four consumables are a temporary attack increase, temporary defense increase, temporary speed increase (or Power restore, still haven't settled on one or the other), and a healing item. I focused on only getting the attack increase working as a learning experience and then the others followed suit once I knew what I was doing.
Getting these items base functionality working is what has consumed this past week.
I had to redo my Input Contexts and put extra checks in my Power code so that the player can't try using Powers and Consumables at the same time, or worse confusing the game and causing a bug.
Next I had to set up some event dispatchers in the Playable Character Blueprint to handle the items being used at the end of an animation, as well as clearing everything once time elapsed.
Actually increasing the attack stat was relatively easy. Setting up a visual timer was not, nor was creating a sort of inventory to limit usage.
The inventory was first. One of the central mechanics of the game is the ability to switch what character is being controlled on the fly (still need to implement this). How Hyrule Warriors implements its items is interesting because they also allow swapping character control, but all the characters share 1 item inventory. This makes it easier to keep track of how many items the player has access to at a given time, and also means they can have one character pick up an item at one end of the map and then have another character elsewhere use it, promoting synergy and tactical play. In order to do this in Unity I just made a scriptable object container, but Unreal doesn't really have something like that so I learned about Game Instances (I also dipped my toes into saving and loading, but that will be a later implementation). Game Instances are agnostic of what map or characters are loaded in and exists for the entirety of the play session, which is what I needed.
As I was working I also stumbled upon and learned about data tables, which are useful for constant things that are set in the editor and then won't change once the game is built. For my usages I implemented them to control how long the items will last, as well as laid the ground work for stat increases when I want to implement a leveling up system. Not a super big deal now, but I thought it worth mentioning for when it comes up in the future.
Finally I had to start building the HUD for the game, and create an aura-style Niagara system for the character. First I cobbled together a rudimentary health bar (as that's what all the tutorials are about), and then I made a graphical timer to show how long the consumable will last, as well as the overlay to show what item each face button will activate. For now I'm just using color coded boxes until I can make or buy actual icons.

A nifty hidden mechanic I've been toying with including is an "Overpowered" state, where the character's stats and max health are increased and they have unlimited Power for a short duration. I mention this now because I was thinking of having this be a rare instantly activated item drop, or by using all 3 buff items when at full health at the same time. Sort of a fun thing in homage to the occasions in Sentai shows where the characters are just inexplicably more powerful and walk through hits like nothing while one-shotting the villain of the week.
Comments