Is it possible to ignore some actors when using a Line of Sight to Actor check?

I’m making some basic enemies for a game, and want them to pursue the player if they can see them. However, there’s lots of enemies in a room at once, and sometimes they block one another’s line of sight, and stop chasing until their buddy moves out of the way.

I can fix this by implementing it more manually, using a LineTraceForObjects instead of a LineOfSightTo, since LineTraceForObjects accepts a list of actors to ignore. I’ve built it that way, and that works fine! But I’m wondering, is there some way of telling an actor that it shouldn’t count for blocking Line of Sight To? It would definitely make my project cleaner to not have to e.g. keep a list of all existing enemies to feed into the ‘Ignored Actors’ array of each LineTraceForObjects check.

I’m not familiar with the LineOfSightTo node, but by using LineTraceForObjects, you can set ObjectTypes to trace. In your case, you can add a custom object type to your player character and then set your enemy only to line trace that specific object type. That being said, there is no need to maintain a list of “Ignored Actors”.

Hm, that could work. The issue there is that I’d need to include all the object types that SHOULD block line of sight (walls, etc.), but thinking about it, making a white list of things that should block rather than a blacklist of things that shouldn’t is probably going to be way easier.

Still would be nice if there were a way to exclude things from a line of sight check, but I’ll implement it this way for now. Thanks!

why not try using a line trace by channel. then you could test on the visibility channel, then if theres no hits then you know there is line of sight.

line of sight to may be a better way to go but i dont see any way to ignore certain actors like what your looking for.

The solution I went with is basically exactly that! All I did differently was make a custom channel instead of using the default Visibility one, so as to not have to mark the enemies as ignoring the core Visibility channel, in case I want to use that for e.g. targeting player weapons or something.