# Import the UI module so we can talk to the HUD elements. # Think of this as plugging into the electrical grid. using { /Fortnite.com/UI } using { /Fortnite.com/Devices } using { /Fortnite.com/Playspaces } using { /UnrealEngine.com/Temporary/Diagnostics } using { /Verse.org/Simulation } # Define our actor. This is the "box" in the map that runs the logic. test_stealth_mode_actor := class(creative_device): # We need a reference to the Trigger Volume to know when someone enters. # In a real build, you'd drag the Trigger Volume from the editor into this slot. # For this example, we assume we have a trigger named "stealth_trigger". @editable stealth_trigger: trigger_device = trigger_device{} # This function runs when the actor is created (when the map loads). OnBegin(): void = # 1. Get the HUD Controller. # This is like finding the main breaker box for the screen. HudController := GetPlayspace().GetHUDController() # 2. Identify the Build Menu. # This is the specific "name tag" for the build menu UI element. BuildMenuId := creative_hud_identifier_build_menu{} # 3. Listen for the trigger. # When someone enters the box, we hide the menu. # When they leave, we show it. stealth_trigger.TriggeredEvent.Subscribe(OnTriggered) # Handler called when the trigger fires. OnTriggered(MaybeAgent: ?agent): void = if (Agent := MaybeAgent?): if (Player := player[Agent]): # Hide the build menu for this player HudController := GetPlayspace().GetHUDController() BuildMenuId := creative_hud_identifier_build_menu{} HudController.HideElementsForPlayer(Player, array{BuildMenuId})