What is the best way for ranged AI characters to detect non-pawn actors?

I’m a fan of using line traces and breaking the hit result. That’s how I’ve been handling this sort of thing. I’ve whipped up a little example for you. In this example we get all actors of the class you want to target and can pull variables from the enemy actor to determine if they’re hostile or not (here I use a faction int).

Hope this helps!

I have a ranged AI character that starts attacking the players when it sees them. It’s using pawn sensing to detect the player. Apart from pawns, I have certain other actors in the level that the AI is trying to destroy. At the moment, I’m using an extra sphere collision component [overlap] to have the AI bots detect these non-pawn actors. And it’s working fine.

But I would like to get some input from the community here as to whether it’s the best way to go about with this. I have at the most two of these non-pawn actors that the AI is trying to destroy. So the AI bots have a reference to the one that they are trying to destroy right from the moment that they are spawned. Is there any better alternative to using the sphere collision in this scenario?

Hi

Just a thought, you said you only 2 at most. You know where they both are.

Why not just compare locations, and if location is with x then run a line trace to see it can see the actor, if so attack, if not then continue doing what you are doing.

Just another thought.

Thanks, I think I’ll go with that. Since the pawn sensing is being called every .5 seconds, I think I can squeeze in a distance check along with that.