Verse Library verse

01 2 Set Up Leash Devices

Manages guard spawn events, patrol paths, and applies leash radius constraints.

extracted-snippets/documentation/en-us/uefn/verse-stronghold-template-2-add-leashes-in-unreal-editor-for-fortnite/01-2-set-up-leash-devices.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/verse-stronghold-template-2-add-leashes-in-unreal-editor-for-fortnite
# Local doc:  epic-docs/documentation/en-us/uefn/verse-stronghold-template-2-add-leashes-in-unreal-editor-for-fortnite.md
# Section:    2. Set Up Leash Devices
using { /Fortnite.com/AI }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Random }
using { /Verse.org/Simulation }
# Defines a leash volume that can be assigned to guards
stronghold_leash_position := class(creative_device):
    # Leash is applied by default to all guards spawned by those devices
    @editable
    GuardsSpawners:[]guard_spawner_device := array{}
    # Guards on those patrol paths can go outside the leash (only one device per path)
    @editable
    PatrolPaths:[]ai_patrol_path_device := array{}
    # Set the leash inner radius. This value must be in centimeters.
    # This defines the volume that must be reached when this leash is assigned to guards
    @editable
    LeashInnerRadius<private>:float = 2300.0
    # Set the leash outer radius. This value must be in centimeters
    # This defines the volume in which guards must stay in when this leash is assigned
    @editable
    LeashOuterRadius<private>:float = 2400.0
    # List of guards currently assigned to this leash
    var<private> Guards : []agent = array{}
    OnBegin<override>()<suspends>:void=
        for (GuardSpawner : GuardsSpawners):
            GuardSpawner.SpawnedEvent.Subscribe(ApplyLeashOnGuard)

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