UNIT 18 WIDGETS AND BLUEPRINTING

 

 

A widget in the Unreal Engine is a specific tool for applying information to the HUD.  Widgets are used within a string of procedural programming, or referred to, to display visual information connected directly to actions performed in the game or just to display information, such as prompts, menu screens, actions completed, or damage received or given.

The first  use of a widget in game is the menu system, so this is where I will start.

It is good practice to create your menu in the first level (permanent level) of your game, with all subsequent levels used for each level of your game.

In the viewport I accessed the content browser, created a file and called it widgets. To the right of this folder, in the empty box I right clicked, hovered over user interface, and selected the widget blueprint, renaming it Main Menu.

Next I went to the level blueprint and created an event begin play node, executed a string to create widget and labelled it Main Menu. I then added an add to viewport, set the mouse cursor to active and enabled click events, added in a player controller binding it all to the persistent level. To be able to see this on the viewport I needed to create a custom event to add a new execution string to my code. Telling the system to load it to my level, before removing it and setting my cursor visibility to off.

I implemented sliding doors on my level to open as you approached. I achieved this with a matinee and a trigger box. The code was simple too. When the player entered the trigger box the matinee would play.

door code

On one of the doors I added the extra effect of requiring a key hidden somewhere in the level to unlock it. Again I used a simple trigger box and matinee to achieve this. Instead of the matinee being localised to my locality it would occur across the map.

The key used to open the door needed to notify us of its interaction, then disappear from the scene. I did this with a trigger box and code. So when the player entered the box a message would appear on screen notifying that we had picked up the object, then it would be destroyed.

key pickup

In one place of my level, where I had placed another key, I decided to add a slippy floor and change the key pickup to a click event. The slippy floor was easily achieved, the pick up not so, I did not have time to implement it.

The slippy floor was a more complicated procedure, in that it required coding in both the level and, as a reaction to it, the playable character.

Firstly I coded in the level blueprint. Starting with a custom event for ice walking i attached two sets for the enviroment, one for the ground friction the other for deceleration. I then added the same set nodes to another custom event for normal surface walking. Finally I connected all the sets to a character movement node.

next I entered the character blueprint to apply the ground effects to the characters movement.

Being a triggered event I implemented a begin and end overlap and cast them both to my character, one for ice walking, the other for normal.

The final event I added to my level was for the character to die, in an anomaly, and die.

This was accomplished by again adding code to the level and character blueprints.

The level blueprint was again activated by a trigger, the anomaly. then cast to the character. Next I enabled the ragdoll event and before destroying the actor I added a delay, for visual purposes, before executing the command.

To add the effect to the player I moved to the character blueprint and created a custom event for the ragdoll, set it to simulate physics, and added it to the character mesh.

ragdoll

All in all I was happy with my results aswell as the new level of knowledge I had aquired through this process.