Home About Me Projects
Home

Enemy Behavior

The following code is for the tengu enemy, which can either shoot projectiles or dash to the player to perform a melee attack. The tengu's varied enemy behavior presents a unique challenge to the player compared to the other enemies, which only chase after the player to melee attack them. By creating more enemies with unique behavior, players are more likely to remain engaged with combat without it becoming repetitive.

To help players feel powerful when defeating enemies, all enemies are launched away from the player on death. When an enemy is hit, they check to see if they were hit from the left or the right, to make sure that they launch away in the correct direction. If the player killed them with a special attack, they are launched twice as far in order to make specials feel more powerful compared to a normal attack.

Below is a diagram of the finite state machine, including all the transitions between states.

Return to INARI page

Checkpoint System

The save system class for INARI (shown below) builds off of what I learned through creating Brain Agents' cloud save system. The object that holds the player's current save state is initialized when another script attempts to access it, if it was not already initialized, through the use of the property's setter. The buttons on the title screen allow for players to load or create new save data, and the game is saved whenever players pass a checkpoint.

On Start(), the player object calls the below method in the CheckpointManager script to determine where the player should spawn. If the player has not yet passed a checkpoint, the index at which they respawn is 0, which spawns them in at the beginning of the level. If the index is anything but 0, they would respawn at a checkpoint and thus the corresponding event is invoked.

Return to INARI page

Combo Counter

The ComboSystem class subscribes to an event that is invoked when the player hits an enemy, which fires the UpdateCombo() method. The first method shown method restarts the combo reset timer, updates the counter UI, and lowers the amount of time the player has to keep the combo up. The higher the player's combo is, the less time they have to keep it going. The degree at which the combo timer decreases per hit can be set by designers.

The combo counter's UI is handled in the ComboUI class, with two of the class' key methods shown below. The combo meter only shows up after the player has reached a minimum number, which can be determined by designers. Once the counter is showing, the time they have left to continue the chain is shown with a bar. As the bar depletes, its color changes to serve as an extra form of visual feedback.

Return to INARI page