# 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() : 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) : 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)