Your First Ten Minutes
This guide walks through the essential steps you’ll tackle in your first few minutes with Ninja Bot, resulting in a functional roaming and chasing AI.
It is intended to give you a basic overview of Ninja Bot and its common workflows. By the end of this guide, you will have a simple AI agent with three states: idle, roam, and chase. The main trigger between these states is whether the player is sensed or not.
Before starting, make sure the following pre-requisites are completed:
Install and configure Ninja Bot, including the Asset Manager setup.
Use a template, such as the Combat Third Person Template, and verify that a Navigation Mesh is present in the map.
Some guides may suggest using Gameplay Abilities. Having a base character already configured for GAS can be helpful.
It is also recommended that your Gameplay Debugger is configured, so you can inspect the Bot’s perception data and evaluate its active AI states during gameplay.
Create the Perception Configuration
In your Perception Data folder, create a new Perception Sense Profile using the Content Browser contextual menu: Ninja Bear Studio → Ninja Bot → Sense Profile.
Add the Sight sense to the list of senses. Configure Sight Radius to
1200and Lose Sight Radius to1400.Mark Enemies, Neutrals, and Friendlies in Detection by Affiliation.
Set Sight as the Dominant Sense.

Create the Roaming Environment Query
Create an Environment Query that retrieves random locations from the Navigation Mesh.
Add a Pathing Grid Generator with Grid Half Size set to
1000and Space Between set to100.
Add a Distance Test with Float Value Min set to
300and Float Value Max set to1200.
Create the Blackboard
In your AI folder, create a new Blackboard that will be used to store contextual data available to the AI agent.
Create an entry for SensedActor, setting the Key Type to
Objectand the Base Class toActor. Create a new Entry Category named Perception.
Create three new float Key Types: CandidateScore, NormalizedCandidateScore, and AccumulatedAwareness. Add them to the Perception category.
Create an entry for AwarenessLevel, setting the Key Type to
Enum. Set the Enum Name toEBotPerceptionAwarenessLevel. Add this entry to the Perception category.
Create three new Vector Key Types: FirstPerceivedLocation, CurrentTargetLocation, and LastKnownLocation. Add them to the Perception category.
Create one additional Vector Key Type, RoamLocation. Add it to a new category named Roam.
Create the Behavior Tree
Create a Behavior Tree and assign the Blackboard to it.
From the Root node, create a Selector composite node and add the Update Perception Service to it. Match each property to the correct blackboard key.

From the top Selector node, create a Sequence composite node for Combat. Add a Blackboard Decorator to check whether the SensedActor key is set. This Decorator should be configured to abort both itself and lower priority nodes.

Add a Move To Task, using the SensedActor key as the Target Location and an Acceptable Radius of
50. Add an Is At Location decorator using the same parameters, followed by a Force Success decorator. Lastly, add a Wait task set to1 secondwith a Random Deviation of0.2.
From the top Selector node, create another Sequence composite node for Roam. Add a Run EQS Query task using the Environment Query created earlier, and configure it to write its result to the RoamLocation key. Add another Move To task using the RoamLocation key as the Target Location.

Complete the Behavior Tree with another Sequence composite node for Idle. Add a Wait task set to
5 seconds.
Create the State Tree
Create a State Tree using the State Tree AI Component Schema.
Add the Update Perception evaluator.

From the Root node, add a Child State named Combat. Add an Object Is Valid Enter Condition, checking
UpdatePerception.SensedActor.
From the Combat state, add a Child State named Move to Target. Add a Distance Compare Enter Condition comparing the Bot and Target locations, a Move To task targeting
UpdatePerception.SensedActor, and a State Completed transition to the Next State.
Add another state named Wait. Add a Delay task with a Duration of
1.0and a Random Deviation of0.2.
From the Combat state, add a Sibling State named Roam. Create a Vector Parameter named Roam Location.

From the Roam state, add a Child State named Find Location. Add a Run EQS Query task, bind the Result to the Roam Location parameter, bind the Query Owner to the Context Actor, and set the Query Template. Add an On State Completed transition to Next State.

Add another state named Move to Location, and from the Roam state add another sibling named Idle. For Move to Location, add a Move To task and bind the AI Controller from the Context, and the Destination to
Parameters.RoamLocation. Add an On State Completed transition to Idle.
From the Idle state, add a Child State named Wait. Add a Delay task with a Duration of
5.0.
Create the Bot Setup
In your Bot Setup Data folder, create a new Bot Setup using the Content Browser contextual menu: Ninja Bear Studio → Ninja Bot → Bot Setup.
Set the Brain Type to Behavior Tree and assign your Behavior Tree asset.

Create the Bot Setup
In your Bot Setup Data folder, create a new Bot Setup, using the Content Browser contextual menu: Ninja Bear Studio → Ninja Bot → Bot Setup.
Set the Brain Type to State Tree and add your State Tree asset.

Create the Bot Character
Create a new Character and add the Bot Setup Provider Interface.

Double-click
GetBotSetupDatafrom the list of Interface Functions. Drag from the Return Value and Promote it to a Variable. Set the Bot Setup as its default value.
In the Character Defaults, locate the AI Controller Class and set it to
NinjaBotAIController.
At this point, you should have a Bot that roams around the environment until it detects the player. Once the player is sensed, the Bot transitions into a chase behavior and actively pursues the target.