Toggle Prop Visibility with a Verse Trigger Volume
Tutorial beginner compiles

Toggle Prop Visibility with a Verse Trigger Volume

Updated beginner Code verified

What you'll learn

  • How to subscribe to a volume_device's AgentEntersEvent from Verse
  • Calling the <transacts> Hide() and Show() methods on a prop device
  • Managing on/off state with a mutable var : logic flag and the correct set syntax

How it works

A volume_device fires its AgentEntersEvent whenever an agent walks into its volume. In OnBegin we Subscribe a handler to that event (device events are fields, so no () before .Subscribe). Our handler takes an agent and returns void — exactly the shape the event expects — so it does NOT need <decides> or a true? return.

Inside the handler we read a mutable VehicleShown : logic flag. Because Hide() and Show() are <transacts> (state-changing) side effects, the handler is marked <transacts> too. We toggle the flag by explicitly reassigning it with set — remember there is no set X = not X toggle in one step, so we branch. We store the subscription in a field and could .Cancel() it later if we ever wanted to stop listening.

Note: earlier drafts tried set VehicleTarget.Hide[] — that is wrong on two counts. Hide() uses parentheses (it is <transacts>, not <decides>), and set is only for reassigning a var, never for a method call. We just call VehicleTarget.Hide() directly.

Let's build it

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# Toggles a target prop's visibility each time a player enters a trigger volume.
vehicle_visibility_toggle := class<concrete>(creative_device):

    # The volume players walk into to fire the toggle.
    @editable TriggerVolume : volume_device = volume_device{}

    # The prop whose visibility we hide/show. A prop_mover_device also exposes Hide()/Show().
    @editable VehicleTarget : creative_device = creative_device{}

    # Current visibility state. Starts visible (true).
    var VehicleShown : logic = true

    # Handler MUST match the event shape: takes an agent, returns void.
    # Marked <transacts> because Hide()/Show() are transactional side effects.
    HandleTrigger(Player : agent) : void =
        if (VehicleShown?):
            # Hide() uses parentheses — it is <transacts>, not <decides>.
            VehicleTarget.Hide()
            set VehicleShown = false
            Print("Vehicle hidden.")
        else:
            VehicleTarget.Show()
            set VehicleShown = true
            Print("Vehicle shown.")

    OnBegin<override>()<suspends>: void =
        # Device events are fields: subscribe with .Subscribe (no parentheses on the event).
        Subscription := TriggerVolume.AgentEntersEvent.Subscribe(HandleTrigger)
        Print("Vehicle visibility toggle initialized.")

Try it yourself

  • Swap the volume_device for a button_device and subscribe to InteractedWithEvent instead.
  • Add a Sleep(2.0) before Show() in the else: branch to create a timed reveal (the handler would need <suspends> and you'd spawn it).
  • Point VehicleTarget at a hud_message_device and call Show(Player) to flash a message on the entering player's screen.

Recap

You now have a reusable Verse device that toggles a prop's visibility on player entry. The key fixes over a naive version: the event handler returns void (not logic) to match AgentEntersEvent, Hide()/Show() are called with parentheses because they are <transacts>, and the state flag is reassigned with set VehicleShown = ... rather than an illegal set Method[] call.

Check your understanding

Test yourself with an interactive quiz and track your progress + earn XP — free for members.

Turn this into a guided course

Add Toggling Vehicle Actor Visibility in Verse to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.

Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.

Comments

    Sign in to vote, comment, or suggest an edit. Sign in