Skip to content

Add HUD in VR


Create a Material called M_HUD
image.png
Create texturesampleparameter 2D, name as SlateUI, set sample source and material expression as follow:
image.png
image.png
Connect as below (to stop seeing the UI even in front of us)
image.png
select M_HUD node, tick didsable depth text (make sure UI appear in front of everything)
image.png

Create a HUD Widget, add progress bar and text, set bar style, appearance and progress as follow:
image.png
Go to graph, add variable , then bind it in percent in progress bar
image.png
image.png


Open VR Pawn, viewport,
add Widget in component called HUDWidget, root under Camera
change its widget class to HUD in details
image.png
set draw size to 1920x1080, adjust the transform. change the material to HUD mtl:
image.png
Collision prest change to NoCollision (player shouldn’t be able to interact on hud bar)
image.png
Drag the VR pawn in scene and see in camera view if the bar in good position: delete the pawn after testing
image.png

Go to VR Pawn event graph, plug out input action trigger left right,
Add varialble as Health, health value as 100:
image.png
Create follow nodes (Clamp max and divide should be 100, not 1 and 0):
image.png
Duplicate the nodes to trigger right, but change - to + after get health
image.png
copy 4 nodes from there to connect to event to begin play node, and add extra as follow, change set health percentage from 0 to 1 (let game beings with full health bar):
image.png

Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.