HUD
A HUD (heads-up display) helps players keep track of specific variables like money or health in a game. They are attached to the player's POV (point of view) so they are constantly visible and do not move when the player looks around.
The experience HUD Demo shows what a basic HUD could look like, and how it works. It is fully remixable and is published on the sandbox and projects hubs.
How to Make a HUD
-
First you need to choose what you want to show in your HUD. Some common HUD elements are:
a. Hitpoints
b. Money
c. Ammo
d. Instructions/Subtitles
e. Mini-maps
Make sure not to overwhelm players with too many HUD elements! -
Once you have decided on what to show, add some text boxes, variables, and/or 3D models to show HUD information. Add the information in the text boxes, and increase the variables you want to show to their default values. For example, if you want a player to start with 10 hitpoints, increase a variable's value to 10.
-
Decrease the Text and Variable's font size to 1 or 2. It should be so small because the HUD aligns directly in front of the player's view, and so appears large because it is so close.
-
Once each HUD element has been created, group each element with its extra pieces (like a variable with a heart 3D model for hitpoints, or a text box and variable for money). Make sure they are aligned along the z-axis so they appear the same size when playing.
-
Then group all of HUD objects together with a Grip Handle, so it can be placed and positioned in the player's head slot.
- Select the Player and add the grouped HUD to their Head slot using the Add Object button.
- Play the Viewer to check the HUD objects position and size. If they are not visible, too large, or offset, then select the Edit Object on the player's Head Slot and re-position/re-size the HUD elements.
-
Add objects around the scene that will interact with the player HUD, like coins to increase the money variable or hearts to increase the heath variable. Make sure include a Trigger around the objects to detect when the player gets close to them and send a message to the HUD to change the HUD variable.
-
On the collectable item's Trigger, add an event that sends a message to the Entering object to change the HUD item's variable, and then destroy the parent object so it can't be collected multiple times.
- Forward the message from the player to their head slot, and then onto the HUD element you want to change. Once received on the HUD element, use events to change the variable by a specific amount. This way you can show hitpoints being increased or decreased, money being spent or earned, ammo pickups, and more!
Test your HUD and collectable objects by Playing the Viewer and trying to collect them!