Hi, i have this basic AI System where the AI wonders around, and if he see’s the player (Using a pawn sensing component) he will chase the player and when he gets close to the player he attacks him.
But when the player runs really far from him and hides inside of a building or somewhere where the AI Can’t see him no more, the AI Still knows where i am no matter what. I Wanna add so that whenever i’m not in his line of sight anymore, he’ll start looking for me at my last known position and search the area (Kinda like in assassins creed) Any help will be highly appreciated!
Also, i ain’t using a behavior tree. This is all done within my ZombieAI Character blueprint.
Can you upload some images of the blueprint? That will help with figuring out what needs to be changed.
Just check with a certain frequency if your npc can see the player (via line traces) and if not record the player’s location in a vector and make your npc go there.
This is basically “ai move to” node with random locations input. And another node is connected through “branch” (true or false) and to “on seeing pawn” is attached to the branch. if true, he will follow the player. if false, it will go back to “delay” node where he continues looking.
.
Based on how far you want him to look around last seen position, change the “get random point in navigable position” value. And the delay is how long he should stand there and look when he reach a place.
Check the image which I attached.
Hope I helped.
This tutorial explains how to implement a search behavior around the last seen position using behavior trees.
Unreal Engine 5 AI - Search last Seen Location.
When player or any of the opponent character identified by an AI NPC character, the character will start moving towards the identified enemy and engage in combat. But, if player manage to break the line of sight, AI character should search the last seen location and if the plyer is not found, sheath weapons and return to regular duties.
Additionally, if you want to visualize the last seen position as a silhouette or a snapshot of the character mesh, this tutorial explains the process.