This section will show you how to set up the leash devices that control the areas that the AI guards will patrol.
A leash is a custom location set in Verse to tell guards where to move. Use a leash to designate locations for guards to patrol in the stronghold.
Guards will only patrol if they have the patrol flag enabled. Otherwise, they will stand still until they see a threat.
In this tutorial, we will use a prop, the Verse device, as a dummy to easily move the center of the leashes.
To create a new Leash Position device, click the Verse header make sure the Verse Explorer is checked.
Next, navigate to the Verse Explorer tab and right-click your project file, then select Add new Verse file to project.
Select Verse device and give it a name, then click Create.
Double-click the device Verse file to bring up the Verse script. Copy and paste the code below.
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
In the Verse tab, select Build Verse Code to compile the Verse script.
From the Content Browser, find the Verse device in All/"Project Name"/Creative Devices/.
Place two Leash Position devices, one for the stronghold leash and one for the fallback leash. You can name them to easily differentiate between the two.
In the Leash Position properties, uncheck Visible in Game so these devices are hidden when playing.
Earlier in the Stronghold Game Manager, you already set the inner and outer radius for the leash.
AI Patrol Path Setup
You can use the AI Patrol Path Node devices to set up with the default patrolling behaviors for the Guard AIs.
To make the AI Patrol Path Node device work as the initial patrolling behavior, set the Guard Spawner’s setting Spawn on Patrol Path Group to be the same value of the AI Patrol Path Node device’s setting Patrol Path Group.
The AI Patrol Path Node device can also be assigned or disabled at runtime through event binding or its associated Verse APIs.
Like the above images, you will need to set the Patrol Path Group option to same number for both the Guard Spawner and the AI Patrol Path Node. Doing this will cause the spawned AIs to pick the patrol path to use.
Debug AI Navmesh
You can turn on the navmesh debug view from the Island Settings and enable both Debug & Navigation options. This would help determine if AIs can navigate to certain locations or not.
Next Section
5. Set Up Audio and Visual Effects
Learn how to set up audio and visual effects to enhance gameplay.