Verse Player Teleportation with a Button and UI Feedback
Tutorial beginner

Verse Player Teleportation with a Button and UI Feedback

Updated beginner

What you'll learn

  • How to subscribe to a button_device's InteractedWithEvent and read the pressing agent.
  • How to move a player instantly using the teleporter_device.Teleport() API.
  • How to fetch a player's HUD with GetPlayerUI[] and confirm they are a real player.
  • How to build and add a text_block widget so the player sees feedback.

How it works

The official fort_character.TeleportTo you may have seen is a <decides> method on storm beacons, not a general "move any player here" call. For moving players reliably, the grounded, supported path is the teleporter device: place a teleporter_device at your destination and call Teleport(Agent) on it. That handles the actual relocation for us.

  1. Place a Button device and a Teleporter device (the teleporter marks the destination).
  2. In OnBegin, subscribe a handler to Button.InteractedWithEvent. Button events send an agent payload.
  3. In the handler, call Destination.Teleport(Agent) to move the player.
  4. Narrow the agent to a player (with player[Agent]) so we can look up their HUD.
  5. Call GetPlayerUI[Player] inside a failure context, build a text_block, and AddWidget it.

Let's build it

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

# A creative device that teleports the pressing player and shows a HUD message.
teleport_button_device := class<concrete>(creative_device):

    # The button players interact with to trigger the teleport.
    @editable
    TeleportButton : button_device = button_device{}

    # A teleporter placed at the destination. Calling Teleport(Agent) moves the player here.
    @editable
    Destination : teleporter_device = teleporter_device{}

    OnBegin<override>()<suspends>: void =
        # InteractedWithEvent sends the agent who pressed the button.
        TeleportButton.InteractedWithEvent.Subscribe(OnButtonPressed)

    # Handler runs each time the button is pressed. Payload is the pressing agent.
    OnButtonPressed(Agent : agent): void =
        # Move the agent instantly to the destination teleporter.
        Destination.Teleport(Agent)
        Print("Teleporting agent to destination.")
        # Show HUD feedback — only players (not AI agents) have a player_ui.
        ShowMessage(Agent)

    # Builds a text widget and adds it to the player's HUD.
    ShowMessage(Agent : agent): void =
        # Narrow agent -> player; GetPlayerUI needs a player and both are fallible.
        if:
            Player := player[Agent]
            PlayerUI := GetPlayerUI[Player]
        then:
            # Create the widget, then add it to this player's HUD.
            Label := text_block{DefaultText := "Teleported!"}
            PlayerUI.AddWidget(Label)

Try it yourself

  • Add a second teleporter_device field and randomly pick a destination each press.
  • Change the DefaultText to interpolate a value: text_block{DefaultText := "Warped {1} time(s)!"} after tracking a counter.
  • Remove the widget after a delay by storing it and later calling PlayerUI.RemoveWidget(Label).
  • Play a sound or VFX by enabling a vfx_spawner_device in the handler.

Recap

  • Button events (InteractedWithEvent) deliver an agent, not a player — narrow with player[Agent] when you need HUD access.
  • Use teleporter_device.Teleport(Agent) to relocate a player; it's the grounded, supported way to move players.
  • GetPlayerUI[Player] is a <decides> call, so it MUST live in a failure context (an if condition).
  • Build widgets like text_block{...} and attach them with PlayerUI.AddWidget(...) for on-screen feedback.

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 Implementing Player Teleportation via TeleportTo 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