Turret attack specified target?

Hello again. I have made a turret and it gets its tracking infomation from “Get player pawn” now that is 0 so my question is how do I set my AI to have an index of say 1 and it will track and attack that corrisponding index instead of me? Also how would I set that index in the relevant agressor?

Many thanks

GetPlayerPawn retrieves only player pawns, and in this sense AIs are not players.

The quickest solution for you would be to implement your own AIController class or Pawn class to have it store an unique ID in its BeginPlay event, and then use GetAllActorsOfClass with your class as a parameter and iterate on the resulting array looking for the ID you wish.



Hi Blakey876,

What you want to do is use cast to nodes to see if the trace hit specific objects/enemies. If you cast to “enemyAI” for example, but it doesn’t see any, it will move on to the next cast, for instance “pawn”. However, if the trace first returns an “enemyAI” cast, then it will ignore your pawn and do whatever actions you tell it to specifically in regards to the AI. I am attaching an image of my example for you to look at:

Ok thanks for the reply. I get my rotation vector based on “Player Pawn” then “Single line trace by channel” checks that the target is Pawn and not a wall or something. How could I change that to track other pawns? Also is there any tutorials on AIController or where I will find my AIController as I am hopeless at C++ and prefer to do all my work via bluprint.

Thanks for your help guys :slight_smile:

If you are doing trace you can set your AI to a specific channel and place that channel in the array. Then when your trace hits you do a cast-to AIController. If it picks up AI controller it will activate that set of functions, if not it will activate another set or do nothing.

Ok all sorted now thank you very much for your help guys :slight_smile: