Week 2: Creating a Health Bar in UE5
This week, to prepare for my DE4402 essay, I wrote a summary of the assignment, followed practitioners on LinkedIn, ArtStation and Instagram, and wrote a blog post of potential practitioners I could interview. For my practice module, I created a functional health bar in UE5, over the course of a few days, using as little direction as possible to try to learn through trial and error rather than just following tutorials step by step. I also challenged myself to use Blender for the first time without using any tutorials to create a 3D model of a lantern to import in to Unreal Engine and use within my level.
The Process:
In the level, the player must travel through a dark cave using rocks, wooden planks and moving platforms to avoid the lava and reach the finish line.
To create the effect of jagged rocks, I distorted the shape of static mesh cubes by activating modelling mode, adding edge loops and using PolyGroup Edit to move, rotate and scale the faces, edges and vertices of the cubes' meshes.
To make the environment look more like a cave, I created a material with a light grey base colour, a specular value of 0.5 and a roughness value of 0.5 to apply to the rocks. I also created a material for the lava using an orange base colour, specular value of 0.5, roughness value of 0.2 and an emissive colour of a pale orange to further light the level alongside the existing directional light.
In the level blueprint, I added background sound effects of a cave environment using Event BeginPlay and Play Sound 2D.
To create moving platforms, I firstly created an actor class blueprint and added a cube and an InterpToMovement component. With the InterpToMovement component selected, in the details panel, I set the duration and control point values and changed the behavior type to Ping Pong to make the platform continuously move between two points.
Since the level was quite dark, I created a simple lantern model in Blender and then imported the model into Unreal Engine and created a black material and a glass material to apply to the two material slots in the static mesh editor.
I then created a new actor class blueprint and added the updated lantern static mesh, a point light and two cubes to create an arm for the lantern. I then added this blueprint into my level and duplicated it multiple times to place lanterns along the cave walls to better light the level.
In Adobe Illustrator, I created a simple pixel-style health bar and imported the full and empty versions of the health bar design to the content drawer in Unreal Engine.
Within a user widget I added a canvas panel and a progress bar. With the progress bar selected, in the details panel I added my background image and fill image and changed the size X and size Y values to match the scale of my png files. I then positioned the health bar in the bottom left corner of the canvas panel and moved the anchor on top of the health bar. In the details panel, under progress, I set the the percent of the progress bar to 100%.
In the third person character blueprint I added a float variable and named it health and set its default value to 100. Next I went back to the health bar widget and pressed bind in the details panel to create blueprints that connect the health value to the widget.
To show the health bar widget within the game, I created a script off of the existing Event BeginPlay node within the third person character blueprint.
In the third person character blueprint, I created a damage system using Event AnyDamage. I also created a sound cue which randomly plays one of two sound clips when the player receives damage.
I created a new actor class blueprint containing a box collision to surround the lava. When this box collision is overlapped by the player they receive damage.
To move the player to safety once they have made contact with the lava, I added an empty actor into the level above a rock and created a blueprint which teleported the player to the location of the empty actor once they had overlapped the trigger box surrounding the lava.

















Comments
Post a Comment