For my first time using Unreal Engine in combination with C++, I created a basic 3D platformer to learn skills in this form of development. Though the gameplay itself is not complex, I included a range of features that I programmed in Rider that I then included in the game world in the engine.
Health/Damage: I created a health component that can be attached to actors, providing them a health value that can be affected on collision. The component has float values for the maximum health and the actor's current health. The current health will decrease when the actor takes damage, which can be done by being hit with projectiles or by walking through lava. The health is unique for each instance of the actor. When the health value reaches 0, the actor it is attached to will die. Damage and death are both controlled through event delegates.
Movement: Movement for the player and for the AI enemies is controlled through an interface. For the player, an input action is received, which then triggers the interface event in the character; these events contain the functionality for moving, jumping, looking around with the camera, and firing projectiles. There are also some slightly more complex movement events: double jumping and wall climbing. Double jumping was created through adding an additional upwards force to the player if they are already in the air from the first jump, and booleans are used to control whether or not the player can jump again before they have landed. Wall climbing is done through changing the player's movement from walking to flying, and making use of the Y axis and upwards vectors. This is activated through colliding with a box component on specific walls with ladders on, which then triggers the functionality to change the movement type. A similar collider exists at the top of the ladder to revert the movement to its original settings.
Timers: Timers were used in various places in this project. One instance was in my speed pickup. Upon colliding with a speed pickup in the level, the player's maximum walk speed is increased to become a value of 2000, rather than 1000. A timer is activated for three seconds, and, on its completion, the walk speed will revert to its original value. Another usage of timers is in my lava hazard. The player is able to walk into the lava, and doing so will start a timer that loops every 0.5 seconds. Each time it loops, the lava will apply 5 damage to the player. The timer is cleared once the player exits the lava.
AI: I used behaviour trees to give my enemies AI functionality. There are two different kinds of enemy in this game: chasing enemies and shooting enemies. The chasers have a task called ChasePlayer. This tasks takes the player's location and the current location of the enemy, and will then move the enemy between locations - it will succeed when the enemy reaches the player. The shooters rotate to face the player on a looping timer. This is done through getting the player's rotation and using linear interpolation to match it from its own original rotation. The actual firing of the projectiles is managed in the same way as the player's firing action, but the firing itself is automated rather than being controlled on an input.
UI: I have UI had updates based on what happens during gameplay. There are two text components that update based on collecting coins and increasing score. There is also a health bar that changes depending on the current health value in the health component; although many actors in the game will have a health component, only the player's will affect the health bar. When the game is completed, either through crossing the finish line or by losing all health, the game will pause and an end-screen will show - depending on the outcome, the background will be green or red, and will display "Game Won!" or "Game Over!". Both screens will show how many points and coins the player collected throughout the game.