Wander Types and Movement - Black-Horizon-Studios/Emerald-AI GitHub Wiki

Wander Type

An AI's Wander Type determines how it moves when not in combat. The Wander Type option can be found within the Temperament tab.

Wander Type Description
Dynamic Allows an AI to randomly wander by dynamically generate waypoints around their Wander Radius.
Waypoints Allows you to define waypoints that the AI will move between.
Stationary Allows an AI to stay stationary in the same position and will not move unless a target enters their trigger radius.
Destination Allows an AI to travle to a single destination. Once it reaches it destination, it will stay stationary.

 

Dynamic - Wander Type

The Dynamic Wander Type does a lot of the work for you. It randomly generates a waypoint anywhere within the green radius. You can adjust the size of this radius and set the slope limitation which stops waypoints from generating on unreachable or too steep locations. Note: The green dynamic wandering radius indicator is only visible within the Temperament tab and not during runtime.

 

Stationary - Wander Type

The Stationary Wander Type allows an AI to stay stationary in the same position and will not move unless a target enters their trigger radius. If an AI attacks and kills a target when using this Wander Type, it will return to the starting stationary destination. Stationary AI will randomly pick an idle animation every Idle Second. An Idle Second is based off of the Min and Max Animation Idle second within the Wander Type tab. An idle animation is randomly picked from an AI's Idle Animation List, which is located within the Animation > Idle tab.

 

Waypoints - Wander Type

Waypoints allow you to create a series of destinations for your AI to move between. AI that are using waypoints will still react to targets according to their Behavior Type. Once a target has been killed, or successfully fled, the AI will resume moving between its waypoints.

Creating Waypoints

Please refer to the guide below for creating a series of waypoints for your AI to follow. This guide assumes that you have already gone through the setup process of creating an AI and applying the needed animations.

Part 1

If you’d like to create your own waypoint system for your AI, you can do so by going to the Waypoint Editor tab located in the Emerald Editor. By default, the Wander Type is set to Dynamic (which randomly generates waypoints). When you open the Waypoint Editor tab, you will see a button to enable waypoints. Once you’ve done this, you will see the waypoint options appear. You can now create a waypoint by pressing the “Add Waypoint” button.

Part 2

Pressing the Add Waypoint button initially will create your AI’s first waypoint. After this, each time you press the Add Waypoint button, an additional waypoint will be created. Each newly waypoint will be positioned 1 unit on the Z axis to avoid being placed in the same position as the previous waypoint. This also makes it easier for customizing your AI’s route. The blue line you see that goes from your AI to your first waypoint indicates the AI’s direction to the first point. You must have at least 2 waypoints for your AI to move between. Waypoints are only visible while the Waypoint Editor tab is active for each AI. Multi-Object Editing is not available for the Waypoints tab. There is no cap on waypoints that can be created. When you test your scene, your AI will immediately start following its waypoint, given that it is currently in an active state.

Part 3

If you happen to make a mistake, and need to remove a waypoint that’s located in the middle of 15 points, you can remove that specific waypoint and Emerald will resize itself so you don’t have to start over. If you’d like to completely start over, you also have the option to clear all your waypoints. This can be done by pressing the “Clear All Waypoints” button. Keep in mind that both of these processes cannot be undone. When you play the scene, the AI will follow the waypoints you've set, unless they enter Combat Mode.

Part 4

There are three Waypoint Types which determines how your AI will move through the waypoints.

Waypoint Type Description
Loop When an AI reaches its last waypoint, it will set the first waypoint as its next waypoint thus creating a loop.
Reverse When an AI reaches its last waypoint, it will reverse the AI's waypoints making the last waypoint its first. This allows AI to patorl back and forth through narrow or one way areas.
Random This allows an AI to patrol randomly through all waypoints. An AI will idle each time it reaches a waypoint for as long as its wait time seconds are set. The idle animation that is played is randomly picked from your AI's Idle Animation List.

 

Destination - Wander Type

Destinations are different than waypoints. Destinations allow you to set a point anywhere on the NavMesh and the AI will move to that destination. AI using destinations will not follow any other waypoints and will take the quickest route to get to their set destination. AI that have arrived at their destination will trigger the event ReachEdDestinationEvent(). This can be useful for triggering custom code or quests when an AI arrives at their destination. At anytime, you can change the AI’s destination programmatically by calling the EmeraldEventsManager.SetDestination(Transform Destination) function. This feature can even make it possible for AI to even have schedules through code or a time of day system such as UniStorm. For a working schedule example, see the script here:

Unlike Waypoints, destinations are set through the Temperament tab. To create a destination for your AI, go to the Temperament tab. Once here, change the Wander Type to Destination. This will automatically create a destination point for your AI.