How do I get an AI to follow another AI?

I understand how to get the AI to follow the player / chase the player. I do that by casting a custom event to the player, having a get player character node to the cast and then having AI move to from the cast and having the cast as the target actor… this works fine.

The issue I am having is that I can not use this method to get the AI to chase another AI. It simply does not work… I am using a custom event and then casting to the AI, I then have the AI move to and the target actor is of course the AI which I am casting to.

The only issue that comes to mind is that the ‘get player character / get player pawn’ node is only for the playable character… if this is true then what node can I use to plug in to the cast node…?

I can provide screenshots if required.

Thanks.

You should use get controller or Just the cast result should work as An actor refference.

Or you can cast to the AI, get his position, and use the AI Move To node so that the other AI has the destination of the AI you want to follow.
You can create such a blueprint i.e. in the Behavior Tree.

Hey, I can not simply cast to the AI… I need an object to go into the cast node… if I chase the player character its simply ‘get player character’ into the cast to ‘player’ and then go into the AI move to node… but as it is not the player character the ‘get player character or get player pawn’ node does not work. I have also tried ‘get player controller and get AI controller’… none of these object nodes work… what can I do about that? Thanks.

As you already said, the get player character and get player pawn only gets the character/pawn you play.
You can make a variable with your AI, cast to him, and let the other one move to him:

Try something like this:

Here is your Ai Character that will follow another, so simply add an variable with type of Character and set it to public:

Then create an Ai Controller for him or add the following Script to an existing AI Controller:

If you now place your Character, you can select the Character (It can be Ai or normal Player) to follow in the Inspector:

I hope this helps a bit.

Hey thanks for all the info but I simply can not get it to work. I am not very advanced with UE4 yet… I am still a beginner, I have tried doing what you have done step by step but I don’t think I have an AI controller… do I need one? If so how can i create one?

And the last screenshot you have shown I do not understand at all… is that the defualt for the AI that is chasing or the AI that will be chased?

Thanks again.

An Ai Controller ‘controls’ your character.
The Ai Controller itself has a movement component that allows you to move your character.
To create an Ai Controller and select it for your character do these steps:

  1. Create your Character: Right click in Content Browser, select Blueprint Class and select Character. Also add a new Variable with type ‘Character’ and name it like ‘AI Player’. This is the variable that the character knows who to follow.

  2. Create your Ai Controller: Right click in content Browser, go to Blueprint Class and select Ai Controller

  1. Scripting: take the script I posted before, to let the Ai follow another character

  2. Set up character: Now open your character and select under Pawn your Ai class, that the character know, where he can walk and where he should go.

  1. Mesh: Under Mesh you can select a skeletal mesh for your character.

  2. Set up Scene: Now your character is set up. What you now have to is to place your character in the scene and create an NavMesh Bounds Volume. To do so, open the Modes Window and under Volumes, create a Nav Mesh Bounds Volume. You should resize it that all Meshes are in that Box. You can toggle visibility of the computed NavMesh by pressing ‘P’

  1. Ready to go: Now your scene is also set up. To let an character move to another you need to place two of them in the scene. To let the ‘follower’ move to the other character select him in your variable list in Inspector:

Hey, thanks again for the response… I am still so confused… I do not understand which one is the chaser and which one is the one being chased in your example… I have never used AI controllers before in my life and also the node you have that states ‘AI player’ I can not seem to replicate even when I create a variable I can not connect it to the cast and the get actor location… I have 3 screenshots that show my AI zombie controller and the other 2 show me selecting the zombie controller for the zombie character and the chaser… (please be aware the zombie is the one that is being chased). I think I am doing everything completely wrong… I understand how the bounds volume works it is literally just getting an AI to chase another AI… the AI controller… who i setup the AI controller for… is it the one that is being chased or the one doing the chasing?

Thanks again.

To make some points clear:

  • you have to choose the AI controller which you have created for your chaser like you have done it.
  • you can create another AI controller that tells the zombies to run away. You don’t need to assign the zombie ai controller for the zombies.
  • just remove the variable in your controller script.
  • if I see it correctly, to get the target, which the chaser should move to, you can replace the zombie variable node with ‘Get all Actors of Class’ and select Zombie1 (your created character) as class, so that the chaser (the ai controller of the chaser) gets all Zombies in the scene and follows one.

To make something about Ai Controllers clear:

  • the AI Controller is need to find a way in the created AI Nava Mesh.

Something you maybe don’t know:

  • you have to call your custom event somewhere. You can i.e. add Event Begin play Node in front of your AI controller script. Instead of the custom event node. So that the script is started at the beginning you play the game.

Then you need a refference to the AI. but proabally easier is to make an interface wich just holds an vector. Then in the AI you want to follow you need to send a message to the AI that will follow. Getting the object kan be done via an get all actors of class, or hard referering it in a variable.