2D character /w special abilities (UNITY/C#)

Here I have created a 2D character controller that also has special abilities. In the game the character is constantly moving and must use these special abilities to help avoid obstacles.

This is done using an interface. The main character script switches the script set in the interface depending on the state the player is in. These scrips define the characters parameters in each of it’ states. This allows each ability / state to have unique attributes, for example you can execute a “dash” whilst in the freeze state but cannot dash mid “stomp”.











The player variables. These define the various player movements.

Direction – The direction the player is moving in, left or right.

Orientation – Whether the player is the right way up or upside down.

Gravity – Defines the fall speed of the player.

Dash speed – The speed the player moves whilst dashing.

Dash time – The length of the dash.

Dash Zoom – ┬áThe amount the camera zooms in whilst dashing.

Stomp Speed – The speed the player moves whilst stomping.

Double flip max – This defines how many times the flip can when double flip is enabled. Double flip allows the player to flip mid-air.

Shrink multiplier – How much to shrink the player by,

Each ability costs energy to use. Here we define the cost of each, the total energy available, the current energy and the rate at which energy recharges.

These variables keep track of pickups (gems), death count,  the corpse sprite, the ray caster origin points (used to check when the player hits a wall or is on the floor) and the various game manager and UI elements.

A set of booleans that track whether an ability is locked or unlocked.