Open ninjaAI controller BP, add new nodes from Run Behavoir Tree node:
promote variable to create SET node
Go to Behavoir Tree, click New Service
Name as NPCSpeed, open this BP class, create node as follow:
Target node created by: Drag “As AI controller” arrow, then typed by NinjaBP /Character movement→ Get as Ninja BP/Character movement
change Max Walk speed variable to public
Go to ChasePlayer BP, add new variable, set as blackboard selector
Add new nodes between simple move to location and finish execute (tick success too):
Back to Behavior Tree, R click on Random Roam Sequence, add Service → choose NPCSpeed
Change its max walk speed to 100
Copy and paste the NPC speed to Chaseplayer side Sequence, this time change the max walk speed to 400
Go to Blackboard, add bool new key, name as KeepFollowingPlayer?
back to behavoir tree, choose ChasePlayer node, change New Var 0 to KeepFollowingPlayer?
Add newboard based conidition on Random Roam Sequence (R click, Add Decorator, Blackboard)
Change its condition in detail as follow:
P.S. If delete blackboard based condition on chastplayer side, enemy will keep running and chasing u even u are out of their sight, once they find you
Improve ninja animation between walk and run:
Go to ninja walk animaiton, change rate scale to 0.5
Go to blandspace 1D, drag walk keyframe from 200 to 100 in speed