This is my 50th Tutorial!

In this quick tutorial I will add notification in HUD telling player how much time he need to survive.

This Tutorial has been created using Unreal Engine 4.10

Make sure you are working on the same version of the engine.

Live Stream

You can watch Live Stream of developing this Tutorial:

Updating ShooterGameInstance

Open ShooterGameInstance and add one new variable:

CurrentLevel (LevelData structure)

And one new function named SetCurrentLevel with one LevelData input:

Updating PatternManager

Open PatterManager and add those variables:

Var Name Var Type Default Value Description CustomLevelTime bool Editable. This will tell the manager to get the level time from GameInstance or should use MaximumLevelTime default. LevelID int Editable. ID of the level that manager was put in. If CustomLevelTime is false we will get the level from game instance using ID.

Open Event Graph and add one new Function named GetLevelTime:

So basically when we haven’t set CustomLevelTime this function will get the time from LevelID.

Now update the BeginPlay to check CustomLevelTime:

And that’s all here!

Creating UMG

Now create new widget named HUD_LevelTime. Open it and add those variables:

Var Name Var Type Default Value Description GameStateRef GameplayGameState Reference It will store reference to GameplayGamestate. CurrentLevelProgress float Editable. Will store level progress and will be bound to progress bar.

In Designer there should be:

Progress bar,

Text,

You can find how to create the UMG here.

Open Event Graph and add Construct and Tick events like here:

Remember to bind CurrentLevelProgress to ProgressBar!

Adding UMG to Player

Open GameplayCharacter and duplicate HUD_Points Widget – name it HUD_LevelTime. Here’s the details:

Location: (X=-7.986629,Y=28.048374,Z=34.133759)

Rotation: (Pitch=9.020610,Yaw=116.542816,Roll=94.183029)

Draw Size: (X=480,Y=200)

Pivot: (X=1.000000,Y=0.000000)

Widget Class: HUD_LevelTime

And that’s all! You should see level time now!