I have an enemy actor (say, the Shooter), who aims at the player and fires if it is in range. However, the Shooter will fire at walls that the player is hiding behind even though the Shooter wouldn’t be able to see the player. So, I implemented a sphere sweep to see if the player is visible. This works as the sweep returns the wall instead of the player and the Shooter holds fire.
However, if the player is poking their body past the edge of the wall the sweep still picks up the wall first and the Shooter doesn’t fire. A line trace (or a smaller sphere) would be smaller and would miss the wall if the player origin is past the edge of the wall, but that doesn’t catch all cases either.
Is there a way to sweep with a sphere (or anything else) and determine if the player is partly visible past a wall, and then target at the player’s impact point without randomly peppering the region with line traces hoping for a hit? Do I have to line trace to the edge of the players static mesh and sample a circle around the player origin (and if so how do I get the edge location dynamically), or is there a better way?
I’m working in C++, and probably just need a pointer in the right direction (if it is possible). I expect there is a sweep or trace that would do this sort of thing, I just haven’t been able to find it.
Thanks for any help!