Download

AI chase AI problem. Stall on find actor location.

Greetings,

I’m trying to create a basic set up with AI chasing and attacking other AI in a level using behaviour trees. Specifically I’m trying to adapt the AI from this video Unreal Engine 4 Tutorial - AI - Part 3 Chasing the Player - YouTube to chase other AI instead of the player. I’ve had a search on the forum and other sites and have had difficulty finding solutions to this problem which make use of behaviour trees.

I’ve come across a couple of forum posts which relate to what I’m doing but there’s still a bug.

To add to the stuff from the video I found this post about adding a character variable inside of the blueprint of my AI which can then be referenced as the location actor…

https://answers.unrealengine.com/questions/506898/how-do-i-get-an-ai-to-follow-another-ai.html?sort=oldest

Also found mention of this in another post…

https://answers.unrealengine.com/questions/667766/making-ai-chase-things-other-than-players.html

Where Mieszko mentions about the ‘Other Character’ is ‘None’. I believe this is referring to the character variable talked about in the post I linked before which can be set in the level editor once the variable is exposed.

Okay so here’s my stuff…

First is my NPC BP. Here I have the AIPerceptionStimuliSource with the sight perception configured in details. I’ve also added the character variable:


Next is the scene showing the NPC variable is set to NPC:

Next is my zombie AI blueprint again showing the variable for character. As far as I’m aware this variable isn’t actually needed at this stage because I only have the zombie containing the code to detect and chase the NPC AI whereas the NPC AI only has move to random location code. I’ve added this variable with the assumption I’ll have something perceive the zombie AI later.


Next is my Zombie AI Controller. Here I have changed the node for ‘Cast to ThirdPersonCharacter’ to ‘Cast to NPC’. This is the blueprint for my NPC character. I believe this should now enable the zombie AI to see the NPC ai and is setting the ‘CanSeePlayer’ blackboard entry to true.

Next is my task in the zombie behaviour tree for finding the location of the NPC character. Here again I have adapted the graph from the AI chase player to now chase the NPC AI. I have cast to the NPC blueprint, got the character variable and I’m passing this location to the TargetLocation value on the blackboard.


Below shows the character variable on the zombie exposed.
Finally is my behaviour tree for the zombie AI. This screenshot is taken during play whilst the AI has stalled out. This is where it gets stuck and never actually passes to the simple parallel.

I’ve tried to play around with the character variable by adjusting it on both the zombie and NPC between none, zombie and NPC values but all of the combinations seem to yield the same result. The NPC marches around happily while the zombie will wonder and then stall.

I have looked at the AI debugging tool and I can see that the NPC is being ‘seen’ by the zombie when it passes within its view radius and this is represented by the green ball on the perception debug. I can also see in my behaviour tree that the blackboard value for ‘CanSeePlayer’ also switches to true. But from there, the zombie doesn’t move.

If anyone could point out any errors or explain to my why this isn’t working I’d really appreciate it. Similarly, if you know a better way of accomplishing this that doesn’t require C++ knowledge (haven’t got that far yet) please point me in the right direction.

Best wishes.