# We assume you placed a device named "GuardLeashPoint".
LeashPosition := World.GetDevice<LeashPositionDevice>("GuardLeashPoint")
# 3. Get the Leash Interface from the Guard.
# This is like checking if the Guard has the "Leashable" trait.
# If the Guard isn't a Guard-type NPC, this might fail or return empty.
Leashable := Guard.GetFortLeashable[]
# 4. Apply the Leash!
# We tell the Leashable interface to tie the Guard to the LeashPosition.
# The second argument (15.0) is the radius in meters.
# The guard will stay within 15 meters of the LeashPosition.
Leashable.SetLeash(LeashPosition, 15.0)
GetFortLeashable
method(InCharacter: fort_character).GetFortLeashable<public>()<transacts><decides>: fort_leashable
Get the current fort_leashable interface for the specified character.
- Module
- /Fortnite.com/AI
- Declared in
- AI
- Source
- fortnite
Used in
NpcSystem / Npc Statemachine
verse-source
SetPatrolPath():void=
if:
PatrolDevice := PatrolPath?
NpcData := GetNPCData[GetAgent[]]
# We check to make sure the NPC is a guard type NPC with the leashable interface
Leashable := NpcData.InCharacter.GetFortLeashable[]
Patroller := (0)
then:
if (DebugAI?) then DebugNpc("NPC is Guard Type and needs a Patrol Path", ?Duration := AIDebugDrawTime, ?TextColor := NamedColors.Cyan)
Logger.Print("{NPCName} - Patrol Device is Enabled")
PatrolDevice.Enable()
if (DebugAI?) then DebugNpc("Patrol Device is Enabled", ?Duration := AIDebugDrawTime, ?TextColor := NamedColors.Cyan)
PatrolDevice.Assign(NpcData.InAgent)
if (DebugAI?) then DebugNpc("Patrol Path Set, SubScibing to Events", ?Duration := AIDebugDrawTime, ?TextColor := NamedColors.Cyan)
PatrolDevice.PatrolPathStartedEvent.Subscribe(PathStarted)
PatrolDevice.PatrolPathStoppedEvent.Subscribe(PathReached)
else:
if (DebugAI?) then DebugNpc("No Patrol Device or Agent not Guard Type", ?Duration := AIDebugDrawTime, ?TextColor := NamedColors.Red)
NpcSystem / Animal Npc Behavior
verse-source
if (NPCData := GetNPCData[GetAgent[]]):
if (DebugAI?) then DebugNpc("{NPCName} - Pet Follow", ?Duration := 5.0, ?TextColor := NamedColors.Cyan)
# Use existing leash system to follow player
if (Leashable := NPCData.InCharacter.GetFortLeashable[]):
Leashable.SetLeashAgent(NPCData.InAgent, PetFollowInnerRadius, PetFollowOuterRadius)
set NPCData.SessionData.IsFollowing = true
set NPCData.SessionData.PetOwner = option{CommandAgent}
Bark()
# Stay in follow mode until interrupted by another command
race:
PetCommandSignal.Await()
loop:
Sleep(5.0)