using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Native }
# This is our main device. It holds the code.
health_bar_device := class(creative_device):
# This is a variable. It holds the current health.
# It starts at 100.
var current_health: float = 100.0
# This is a variable to track the health percentage for the UI.
# We will update this to drive the visual bar.
var health_percentage: float = 1.0
# This function runs when the game starts.
OnBegin<override>()<suspends>: void =
# First, we set the initial health.
# We send 1.0 to the UI. 1.0 means 100% full.
set health_percentage = 1.0
Print("Health bar is ready! Press Space to take damage.")
# This function reduces health when called.
TakeDamage(): void =
# Let's take some damage.
set current_health = current_health - 25.0
# Check if health is below zero.
if (current_health < 0.0):
set current_health = 0.0
Verse Library
verse
01 Device
Class-based health bar controller that tracks damage, calculates percentages, and updates UI visuals in real time.
verse-library/creating-custom-ui-with-material-instances-in-unreal-editor-for-fortnite/01-device.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.