Making AI behavior tree and BP target more than just the index 0 player


For context, I’m making a multiplayer game where there is an enemy that roams around and chases a player when it senses it in view. I’m trying to make it so that the AI Enemy I made doesn’t just target the index 0/BP_Hero1 player when it senses that pawn. I understand that it is because I am casting it to the BP_Hero1 in the 1st image. Furthermore, in the 2nd image I understand that it is only going to target the Index 0 player since that’s what I’m setting the target actor to. I’m just super confused on how I could make it so that it picks any player to chase in its view rather than the index 0 player.

I’m new to Unreal Engine so any feedback helps :smile:

In your current setup, the simplest way to get this to work is to save the pawn that was detected in OnSeePawn to a variable (assuming it passes the cast check), and then use that cached variable as the input to TargetActor for your MoveTo section.

You can save it to a custom Blackboard entry or you could use the AI’s current AIController to cache it somewhere else (a member variable on the AIController, or the possessed Pawn, etc.). If you use a custom Blackboard entry just make sure the Instance Synced flag is NOT checked so that each individual Blackboard can track its own target.