Make Your Loot Box Fly: Verse for Moving Props
Tutorial beginner compiles

Make Your Loot Box Fly: Verse for Moving Props

Updated beginner Code verified

Make Your Loot Box Fly: Verse for Moving Props

Stop building static loot boxes that just sit there gathering dust. If you've ever wanted a chest that launches into the air when you shoot it, or a trapdoor that slides away to reveal a secret, you need to understand Movable Props. In Verse, we don't just place objects; we define their behavior. In this tutorial, we're going to turn a boring, stationary prop into a dynamic, flying object that reacts to your presence. No more static scenery—let's make things move.

What You'll Learn

  • Variables vs. Constants: How to store settings like "how fast should this thing fly?" so you can tweak them without rewriting code.
  • The Scene Graph (Hierarchy): Understanding which object is the "boss" (the root) that controls the movement of its children.
  • Editable Properties: Using @editable tags to let you change code settings directly in the UEFN editor, like adjusting the storm timer but for physics.
  • Transforms: The math behind where an object is, how it's rotated, and how big it is.

How It Works

Imagine you're setting up a trap. You place a tripwire, a detonator, and a bunch of dynamite. When the tripwire is triggered, the dynamite doesn't just appear; it moves from its hidden spot to the center of the room.

In programming terms, we need to tell the computer three things:

  1. What is moving? (The Prop)
  2. Where is it going? (The Target/Transform)
  3. How does it get there? (The Animation/Duration)

Variables: The Loot Pool

In Fortnite, your inventory changes as you pick up items. In Verse, a Variable is like your inventory slot—it holds a value that can change. We'll use variables to store the time it takes for our prop to move. If we set it to 1 second, it zips. If we set it to 10 seconds, it floats like a feather.

Constants: The Blueprint

A Constant is like the skin you equip before the match starts. Once the game loads, you can't swap it mid-air (usually). We use constants for things that shouldn't change, like the name of our script or a fixed damage value. For this tutorial, we'll stick to variables because we want to tweak the speed.

The Scene Graph: The Squad Leader

Fortnite's editor uses a Scene Graph. Think of this like a squad hierarchy. You have a Root Prop (the leader). If the leader moves, everyone in their squad moves with them. If you want a crate to fly, the crate is the root. If you want a crate with a fire particle effect inside to fly, the crate is still the root, and the particles are its squad members. We must define the root so Verse knows what to grab and throw across the map.

Editable Properties: The Creative Console

You don't have to recompile code every time you want to change the speed. By using the @editable tag, we create a property that shows up in the UEFN Inspector panel. It's like the slider on a Creative device that lets you set "Damage" or "Cooldown." We'll use this to make our flying speed adjustable without touching the code again.

Let's Build It

We are going to create a Launch Crate. When placed, it will animate from its starting position to a target position over a set duration.

Step 1: The Setup

  1. Open UEFN and create a new Verse file (e.g., LaunchCrate.verse).
  2. Place a Creative Prop in your island. Let's use a simple crate or barrel.
  3. In the UEFN Inspector, note the name of this prop. We'll need it.

Step 2: The Code

Here is the complete, annotated Verse code. Copy this into your file.

# This script defines a prop that moves to a target location.
# It uses the MovableProp system to handle the animation.

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

# Define our class. This is the "Blueprint" for our moving prop.
# creative_device gives it a presence on the island and an OnBegin event.
LaunchCrate<public> := class(creative_device):

    # ---------------------------------------------------------
    # EDITABLE PROPERTIES
    # These show up in the UEFN Inspector. You can change these
    # without touching the code. Think of these as your "Device Settings."
    # ---------------------------------------------------------

    # The prop that will actually move.
    # You must drag your Creative Prop from the editor into this slot.
    @editable
    RootProp: creative_prop = creative_prop{}

    # How long (in seconds) the movement takes.
    # 1.0 = fast, 5.0 = slow float.
    @editable
    MoveDuration: float = 2.0

    # The target offset added to the prop's starting position (in centimetres).
    # Z=500 lifts the prop 500 cm (5 metres) straight up.
    @editable
    TargetOffset: vector3 = vector3{X:=0.0, Y:=0.0, Z:=500.0}

    # ---------------------------------------------------------
    # CORE LOGIC
    # ---------------------------------------------------------

    # OnBegin is called automatically when the island session starts.
    # It is async, so time-based operations like Sleep() and Move() work here.
    OnBegin<override>()<suspends>: void =
        StartMovement()

    # This function drives the movement.
    # '<suspends>' means it can pause and wait without freezing the game —
    # equivalent to the 'async' concept described above.
    StartMovement()<suspends>: void =

        # Get the prop's current transform (position/rotation/scale).
        # This is like checking the prop's current GPS coordinates.
        CurrentTransform := RootProp.GetTransform()

        # Build the target position by adding TargetOffset to the
        # prop's current world location.
        # Think of this as "Keep looking forward, but walk to the new spot."
        TargetLocation : vector3 = CurrentTransform.Translation + TargetOffset

        # Construct the destination transform, keeping the original
        # rotation and scale but swapping in the new location.
        TargetTransform := transform:
            Translation := TargetLocation
            Rotation    := CurrentTransform.Rotation
            Scale       := CurrentTransform.Scale

        # MoveTo animates the prop smoothly from its current transform
        # to TargetTransform over MoveDuration seconds with a linear curve.
        # This is the magic line that makes it move smoothly.
        # '<suspends>' lets the caller await completion automatically.
        RootProp.MoveTo(TargetTransform, MoveDuration)

        # Execution continues here only after the movement finishes.
        # Optional: Play a sound or spawn particles here when it arrives!```

### Walkthrough: What Just Happened?

1.  **`class(creative_device):`**: We created a blueprint called `LaunchCrate` that inherits from `creative_device`. This is like drawing the plans for a new device.
2.  **`@editable`**: These lines create slots in the UEFN Inspector. When you place this script on a prop (or link it to one), you'll see fields for "Move Duration" and "Target Offset." You can type numbers directly into the editor.
3.  **`OnBegin<override>()<suspends>: void`**: This is the automatic entry point that fires when the island session starts. `<suspends>` is the real Verse keyword that marks a function as capable of pausing over time — it's what makes the prop glide across the screen while the game keeps running.
4.  **`GetTransform()`**: This grabs the prop's current position, rotation, and scale. It's like asking, "Where are you right now?"
5.  **`MoveTo`**: This is the heavy lifter. It tells the prop: "Take `MoveDuration` seconds to slide from where you are to `TargetTransform`."

## Try It Yourself

The code above adds a static offset. But what if you want the prop to fly to **wherever the player is standing**?

**Challenge:**
1.  Add a new editable variable called `TargetProp: creative_prop` to your class.
2.  In the `StartMovement` function, instead of using the hardcoded `TargetOffset`, get the transform of `TargetProp`.
3.  Set your `RootProp` to a crate and `TargetProp` to a player spawn point or another marker in the editor.
4.  Run the island. Does the crate fly to the target?

**Hint:** You'll need to use `TargetProp.GetTransform()` to get the position, then extract the `.Translation` from that transform to set your `TargetTransform`.

## Recap

You've just built your first moving prop system in Verse. You learned that:
*   **Variables** hold changing data (like move duration).
*   **Editable Properties** let you tweak settings in the editor without coding.
*   **Transforms** define position, rotation, and scale.
*   **Suspending Functions** allow time-based actions like animations without freezing the game.

Now go make some loot boxes launch, elevators rise, and traps snap shut. The island is yours to move.

## References

*   https://dev.epicgames.com/documentation/en-us/fortnite/animating-prop-movement-1-making-movable-props-in-verse
*   https://dev.epicgames.com/documentation/en-us/fortnite/animating-prop-movement-6-combining-movement-rotation-and-scale-in-verse
*   https://dev.epicgames.com/documentation/en-us/uefn/animating-prop-movement-6-combining-movement-rotation-and-scale-in-verse
*   https://dev.epicgames.com/documentation/en-us/uefn/animating-prop-movement-3-translating-props-in-verse
*   https://dev.epicgames.com/documentation/en-us/uefn/animating-prop-movement-1-making-movable-props-with-verse-in-verse

Verse source files

Turn this into a guided course

Add Defining Props that Move 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