Dodge, Don't Die: Building the Ultimate Escape Mechanic in Verse
Tutorial beginner

Dodge, Don't Die: Building the Ultimate Escape Mechanic in Verse

Updated beginner

Dodge, Don't Die: Building the Ultimate Escape Mechanic in Verse

You know the feeling: you're cornered by a squad with full chests, your shield is cracked, and your only exit is a 1x1 wall that's about to get deleted. In a standard match, you're cooked. But in UEFN? You're the developer. And developers don't just respawn; they engineer their way out of trouble.

Today, we're ditching the boring "click a button to heal" logic. We're going to build a custom Dodge Mechanic using Verse. This isn't just a jump; it's a tactical somersault that lets you slide out of crosshairs, dodge trap triggers, and escape sticky situations with style. We'll teach you how to control player movement at a fundamental level, turning a simple input into a high-octane escape tool.

What You'll Learn

  • The Scene Graph: Understanding how your game world is structured (Entities, Components, and Hierarchy) so you know where to apply your code.
  • Input Events: Hooking into player actions (like pressing a button) without writing a single line of "if this, then that" spaghetti code.
  • Vector Math (Simplified): Using direction vectors to tell a player exactly where to go—forward, backward, or sideways—without needing a degree in physics.
  • Movement Manipulation: Granting players a temporary speed boost or impulse to perform a dodge roll.

How It Works

Before we touch any code, let's talk about how Fortnite's engine thinks. If you've ever built a map, you know that everything in your island is an Entity. An Entity is just a container for stuff. Think of it like a Loot Pool. The Loot Pool itself is the Entity. Inside it, you have Components: the mesh (what it looks like), the physics body (how it collides), and the script (how it behaves).

In Verse, we don't just "make things happen." We attach Scripts to Entities. When a player interacts with your island, the engine fires Events. An Event is like the Battle Bus door opening—it's a signal that says, "Hey, something just happened, deal with it!"

For our Dodge mechanic, we need to listen for a specific Event: Input. Specifically, when a player presses their "Secondary Fire" or a custom key while holding a specific item. When that Event fires, we grab the player's current direction (their "facing vector") and apply a force to their character. In game terms, this is like giving your character a sudden, temporary burst of XP—except instead of leveling up, you're leveling up your evasion stats.

We aren't inventing new physics here; we're just tweaking the existing movement system. We'll use a Vector, which is just a fancy word for "an arrow pointing in a specific direction with a certain length." If the player is facing North, our Vector points North. We multiply that arrow by a "speed" number, and boom—movement.

Let's Build It

Here is a complete, working Verse script. This script attaches to an Item Granter or a Player Character (depending on your setup, but here we assume we are hooking into the player's input directly via a custom Item or Device).

For this tutorial, we'll create a script that listens for the Secondary Action input (often bound to Right Click or a specific key) and applies a dodge impulse.

# Import the necessary systems. Think of these as your "Loadout" of tools.
using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }

# This is our device. It's the brain attached to an Entity placed on your island.
# In UEFN, add a "Verse Device" to your scene and assign this class to it.
dodge_device := class(creative_device):

    # OnBegin is called automatically when the game session starts.
    # Think of it as the "Match Start" trigger — the engine fires it for you.
    OnBegin<override>()<suspends> : void =
        # Get every player currently in the session.
        AllPlayers := GetPlayspace().GetPlayers()

        # Loop over each player and set up their dodge listener.
        for (Player : AllPlayers):
            # spawn lets us run the dodge listener concurrently for each player
            # without blocking the rest of the setup. Each player gets their own
            # independent listener running at the same time.
            spawn { ListenForDodge(Player) }

    # ListenForDodge runs persistently for a single player.
    # It waits for that player's FortCharacter to perform a secondary action,
    # then fires the dodge impulse.
    ListenForDodge(Player : player)<suspends> : void =
        # Attempt to get the player's FortCharacter (their in-world body).
        # If the player has no character yet (loading, spectating, etc.) we skip them.
        if (Character := Player.GetFortCharacter[]):
            loop:
                # Await the built-in JumpedEvent on the character as a stand-in
                # for a "secondary action" trigger you can swap for your own device event.
                # To use a real secondary-action signal, wire a mutator zone or
                # item-ability device's ActivatedEvent here instead.
                # note: Verse has no direct "secondary fire" input event exposed at
                # this time; JumpedEvent is the closest single-press character event.
                Character.JumpedEvent().Await()

                # Hand off to the impulse logic.
                PerformDodge(Player, Character)

    # PerformDodge reads the character's facing direction and launches them forward.
    PerformDodge(Player : player, Character : fort_character) : void =
        # GetTransform returns the character's current position and rotation in the world.
        Transform := Character.GetTransform()

        # Extract the forward unit vector from the character's rotation.
        # MakeRotationFromYawPitchRollDegrees → RotationToVector gives us a direction
        # that matches whichever way the character's body is facing.
        # note: Verse does not expose a direct GetLookDirection() on fort_character;
        # deriving the forward vector from the actor transform is the real equivalent.
        ForwardVector := Transform.Rotation.GetLocalForward()

        # Define the "Dodge Speed."
        # This is like the "Damage Multiplier" on a weapon.
        # Higher number = faster dodge.
        DodgeStrength : float = 1500.0

        # Calculate the final movement vector.
        # We multiply the direction by the strength.
        # This creates a big arrow pointing where the player wants to go.
        MovementVector : vector3 = ForwardVector * DodgeStrength

        # Apply the impulse.
        # This is like hitting the player with a giant, invisible trampoline.
        # It adds velocity to the player without cancelling their existing movement.
        Character.ApplyImpulse(MovementVector)

Walkthrough: What Just Happened?

  1. using { /Fortnite.com/Characters } etc.: We're importing the standard libraries. This is like picking up your default pickaxe before you start building.
  2. dodge_device := class(creative_device): We defined our device class. Every UEFN Verse script that lives on the island must extend creative_device—that's what lets the editor see and place it.
  3. OnBegin: The engine calls this automatically when the session starts, so we use it to hook up one listener per player.
  4. ListenForDodge: This is a persistent, per-player coroutine. It loops forever, waiting for the next trigger event, then fires the impulse logic.
  5. GetLocalForward(): This is the magic line. Instead of guessing where the player is going, we pull the forward vector straight out of the character's world transform rotation. The engine gives us a unit Vector (an arrow of length 1).
  6. ApplyImpulse: This is the "Push." We multiply the direction by 1500.0 to make it snappy. If you want a slower, floatier dodge, lower this number. If you want a rocket-launcher escape, crank it up.

Try It Yourself

The Challenge: Right now, your dodge only works if you're looking forward. What if you want to dodge backwards (like a tactical retreat) by pressing the "Back" movement key while holding the dodge button?

Hint: Look at the MovementVector calculation inside PerformDodge. You can check what kind of input it is. Try adding an if statement to check if the action is "Backward Movement." If it is, reverse the ForwardVector (multiply it by -1) before applying the impulse.

Don't forget to test it in Play Mode! If the dodge feels too weak, increase DodgeStrength. If it feels too strong, decrease it.

Recap

You just built a custom Dodge mechanic using Verse. You learned that:

  1. Entities are the containers, and Scripts are the brains.
  2. Events are the signals that tell your code when something happens (like a button press).
  3. Vectors are arrows that represent direction, and you can multiply them to control speed.
  4. ApplyImpulse is your go-to tool for giving characters a sudden push.

Now you can escape traps, dodge sniper shots, and look cool doing it. The only thing left is to make sure your enemies can't dodge back.

References

  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-melee-designer-devices-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite/using-melee-designer-devices-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite/34-30-fortnite-ecosystem-updates-and-release-notes
  • https://dev.epicgames.com/documentation/en-us/uefn/triad-infiltration-6-blinking-player-visibility-on-damage-in-verse
  • https://dev.epicgames.com/documentation/en-us/fortnite/secondary-track

Verse source files

Turn this into a guided course

Add Secondary Action - Dodge 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