I’m trying to make a “patrolling” for my AI by using a Behavior Tree. There’s plenty of tutorials for having your NPC goes to a random location by “Get Random Point…”
But I can’t find a way to tell to my AI : Go here(1), then here(2), then go back to here (1) etc…
I’m working on a Sidescroller in 2.5d so my AI is on a Constraint Plane and I’m actually trying to make it simply goes back and forth.
Why a Behavior tree ? Because it’s easier I think ? Plus, when an enemy see the player, it starts to chase him in a certain range (His sight)
And I don’t know how to tell to the AI to go back to his routine if the player leave his sight range so…
If you guys could give me a hand, i’d appreciate that a lot.
You need Waypoint “system”. Add four vector variables to your Patrol_AI_Character. Two of them expose as 3D widgets. Then add logic to Patrol_AI_Character ConstructionScript. You need vector offset to get world location of each Waypoint.
Now you need Blackboard
1. Waypoint_00_Vkey
2. Waypoint_01_Vkey -patrol points
3. IsPlayerDetected_Bkey - bool variable answers Is player close enough?
4. Target_ObjKey - this ActorKey is Player reference
You need Service to update IsPlayerDetected_Bkey. Patrol_BT_Service. This service check does distance between Patrol_AI_Character and player less then DetectionDistance and set IsPlayerDetected_Bkey. Simple - only distance, no trace. Then set target reference.