Verse Library verse

01 Verse Multiplayer Handler

Handles player teleportation across map areas using trigger events and configurable axis offsets.

extracted-snippets/documentation/en-us/uefn/tmnt-travel-between-areas-in-unreal-editor-for-fortnite/01-verse-multiplayer-handler.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/tmnt-travel-between-areas-in-unreal-editor-for-fortnite
# Local doc:  epic-docs/documentation/en-us/uefn/tmnt-travel-between-areas-in-unreal-editor-for-fortnite.md
# Section:    Verse Multiplayer Handler
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Playspaces }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }

# This device is used to handle teleporting players around the map to ensure all players are always in the action!
multiplayer_teleporter := class(creative_device):

    #The trigger device used to initiate teleporting players
    @editable
    TriggerDevice : trigger_device = trigger_device{}

    # The world axis in which the offset is applied to the teleporting character i.e. X: 0 Y:1 Z:0 will apply the offset in the Y axis
    @editable
    TeleportOffsetAxis : vector3 = vector3{X := 0.0, Y := 1.0, Z := 0.0}

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends> : void=  
        TriggerDevice.TriggeredEvent.Subscribe(TeleportPlayers)
    TeleportPlayers(TriggeringAgent : ?agent)<transacts> : void =

        # Check if the triggering player's agent is valid and then use it's FortCharacter to set TriggeringCharacter
        if (TriggeringCharacter := TriggeringAgent?.GetFortCharacter[]):
            var TeleportOffset : float = 0.0
            CurrentPlayers := GetPlayspace().GetPlayers()

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in