Drive Device Animations with Verse Events
Tutorial beginner

Drive Device Animations with Verse Events

Updated beginner

What you'll learn

  • How to bind Verse callbacks to creative device events like button presses.
  • How to invoke the PlayAnimation module to trigger sequences programmatically.
  • Best practices for keeping your device script alive and managing animation instances.

How it works

In UEFN, devices communicate via events. Instead of relying solely on the visual scripting graph, Verse lets you subscribe to these events using .Subscribe(). When a player interacts, your callback runs inside a <suspends> context, allowing you to call async APIs like Sleep or animation controllers. The PlayAnimation module gives you precise control over playback rates, blend times, and instance states.

Let's build it

Set up a button_device and an animation_sequence in your level. Open Verse, create a new device, and paste the code below. Remember to drag your devices into the matching editable fields in the Outliner.

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

anim_device := class<concrete>(creative_device):

    @editable
    MyButton : button_device = button_device{}

    @editable
    AnimSeq : animation_sequence = animation_sequence{}

    @editable
    AnimCtrl : play_animation_controller = play_animation_controller{}

    OnBegin<override>()<suspends>: void =
        Print("Device started. Waiting for player interaction.")
        # Subscribe to the button's InteractedWithEvent. 
        # The callback captures the agent who triggered it.
        Sub : cancelable = MyButton.InteractedWithEvent().Subscribe(|Agent:agent| OnPress(Agent))
        
        # Keep the coroutine alive to listen indefinitely
        loop:
            Sleep(1.0)

    OnPress<override>()<suspends>(Player:agent): void =
        Print("Interaction detected! Playing animation.")
        
        # Call the real API to start the animation sequence.
        # We pass named arguments for blend rates and playback count.
        ActiveAnim : play_animation_instance = AnimCtrl.Play(
            AnimationSequence:=AnimSeq,
            PlayRate:=1.0,
            PlayCount:=1.0,
            BlendInTime:=0.25,
            BlendOutTime:=0.5
        )
        
        # Example: query the state or stop it later if needed
        # State : play_animation_state = ActiveAnim.GetState()
        # ActiveAnim.Stop()
        Print("Animation sequence initiated.")

Try it yourself

  • Change PlayCount to 0.0 to make the animation loop continuously while the player is near.
  • Add a GetState() call after playing to print whether the animation is Playing, Paused, or Stopped.
  • Wire up an if (Player.GetTeamID()) check inside OnPress so only specific teams trigger the animation.

Recap

You've successfully bridged the gap between traditional UEFN device logic and modern Verse scripting. By subscribing to interaction events and leveraging the PlayAnimation controller, your island now responds dynamically to player actions. Keep experimenting with blend times and playback rates to polish the feel of your interactive props!

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 Driving Device Animations via Verse Interaction Events 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