Survival HUD
Build a classic survival HUD: health / hunger / stamina bars in the bottom-left, ammo counter in the bottom-right, minimap frame in the top-right. ~20 minutes.
Table of contents
- What we’re building
- Step 1 — Create the document
- Step 2 — The bottom-left stat panel
- Step 3 — The bottom-right ammo card
- Step 4 — The minimap frame
- Step 5 — Test in Play
- Step 6 — Compile for real
- Step 7 — Hover effects (optional)
- What you learned
- Next steps
What we’re building
┌──────────────────────────────────────────────────────────┐
│ ┌──────────┐ │
│ │ MINIMAP │ │
│ │ frame │ │
│ └──────────┘ │
│ │
│ │
│ │
│ │
│ ▓▓▓▓▓▓▓░░░ HP 85/100 │
│ ▓▓▓▓▓░░░░░ HUNGER 50/100 ╔════════════╗ │
│ ▓▓▓▓▓▓▓▓▓░ STAMINA 90/100 ║ 30 / 90 ║ │
│ ╚════════════╝ │
└──────────────────────────────────────────────────────────┘
Three regions:
- Bottom-left: stack of 3 ProgressBars with labels.
- Bottom-right: ammo counter card.
- Top-right: minimap placeholder.
Step 1 — Create the document
- Asset Browser → right-click
Assets/UI/(create it if needed) → New Asset → Sbox UI Document. - Name it
survival_hud.sui. - Double-click to open in SUI Designer.
You’ll see an empty 1920×1080 canvas with just the root Canvas element selected.
Step 2 — The bottom-left stat panel
We’ll build a VerticalBox containing 3 stat rows. Each row is a HorizontalBox with a bar + label.
Create the outer VerticalBox
- Drag VerticalBox from the Palette onto the canvas.
- Rename it to StatsContainer (F2 on Hierarchy).
- In Details:
- Anchor: BottomLeft
- X:
40, Y:40(offset from the bottom-left corner) - Width:
360, Height:120 - Gap:
8(space between rows)
- Style:
- Background: leave empty (the rows have their own bg)
Create the Health row
- Drag HorizontalBox onto StatsContainer (drop INSIDE it in Hierarchy, or onto its area in the canvas).
- Rename to HealthRow.
- AlignItems:
Center(so bar and label line up vertically). - Gap:
12.
Inside HealthRow:
- Drop a ProgressBar in HealthRow.
- Name: HealthBar
- Width:
200, Height:18 - Background:
#22222288 - Border Radius:
4 - Props:
- Progress Min:
0, Max:100 - Preview Value:
85 - Fill Color:
#ef4444(red) - Direction: LeftToRight
- Progress Min:
- Drop a Text in HealthRow (after HealthBar).
- Name: HealthLabel
- Text:
HP 85/100 - Font Size:
14, Font Weight: Bold - Color:
#ffffff
Duplicate for Hunger and Stamina
- Select HealthRow in Hierarchy.
Ctrl+Dtwice — you now have HealthRow, HealthRow (1), HealthRow (2).- Rename them to HungerRow and StaminaRow.
- Edit each:
- HungerRow → ProgressBar Fill Color
#f97316(orange), Preview Value50, Label textHUNGER 50/100. - StaminaRow → ProgressBar Fill Color
#22c55e(green), Preview Value90, Label textSTAMINA 90/100.
- HungerRow → ProgressBar Fill Color
Save (Ctrl+S). The canvas should now show the 3-bar stack in the bottom-left.
Step 3 — The bottom-right ammo card
- Drop a Panel on the root canvas.
- Rename to AmmoCard.
- Anchor: BottomRight
- X:
40, Y:40, Width:160, Height:64 - Style:
- Background:
#0f0f12 - Border:
#3b82f6, Border Width:2, Border Radius:8
- Background:
- Layout Mode: Flex
- JustifyContent:
Center - AlignItems:
Center
Inside AmmoCard:
- Drop a Text.
- Text:
30 / 90 - Font Size:
28, Font Weight: ExtraBold - Color:
#3b82f6
- Text:
Save.
Step 4 — The minimap frame
A placeholder frame for the minimap area. The actual minimap image would come from gameplay code at runtime.
- Drop a Panel on the root.
- Rename to MinimapFrame.
- Anchor: TopRight
- X:
40, Y:40, Width:220, Height:220 - Style:
- Background:
rgba(0, 0, 0, 0.6) - Border:
#ffffff44, Border Width:1, Border Radius:8
- Background:
- Drop a Text inside it (as a label).
- Text:
MINIMAP - Anchor: TopCenter, X:
0, Y:8 - Font Size:
12, Font Weight: SemiBold - Color:
#ffffff88
- Text:
Save.
Step 5 — Test in Play
- Set the Output in the right panel:
- Class Name:
SurvivalHud - Namespace:
Game.UI
- Class Name:
- Click Test in Play in the top toolbar.
- The preview stage scene opens, you spawn as a TPS character, and the HUD overlay shows your stats.
Walk around. The bars, ammo card, and minimap frame should be exactly where the canvas drew them.
Stop Play (Esc → Stop button) to exit.
Step 6 — Compile for real
When you’re ready to use this HUD in your game:
- Click Compile (
Ctrl+B). - The folder picker asks where to put
SurvivalHud.razor. PickCode/UI/. - The Compile Results panel shows three files written:
SurvivalHud.razorSurvivalHud.razor.scssSurvivalHud.User.scss(boilerplate; you can edit this)
In your scene, add a ScreenPanel GameObject and add the SurvivalHud component. The HUD overlays the screen.
Step 7 — Hover effects (optional)
Open Code/UI/SurvivalHud.User.scss and add:
SurvivalHud {
// Pulsing red glow when health is low — flip an "low-health" class from C# code
.health-bar.low-health {
box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
animation: pulse 0.8s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.6; }
}
}
Recompile → Play → in your C# component, HealthBar.SetClass("low-health", currentHealth < 30).
What you learned
- Three layout modes used together: Flex for VerticalBox / HorizontalBox / AmmoCard, Absolute for everything else.
- Anchor-based positioning to pin elements to corners.
- ProgressBar configuration.
- Duplicate + edit pattern for repeating UI elements.
- Test in Play vs Compile workflow.
.User.scssfor effects beyond the inspector.
Next steps
- Inventory screen — grid layouts, slot interactions.
- Death modal — full-screen overlays with countdown.