I want to check at runtime, if an Object/Mesh is occluded by something, respectively if its visible by the player.
The only way i found so far, are line traces. But thats not really a optimal solution to determine if something is visible.
Does anyone know a better, more reliable solution?
The purpose is an Attack, that is launched by the player and that should only hit Targets which are not occluded by anything.
I know, i probably could use occlusion culling in combination with the “was recently rendered”-Node.
But that wouldn’t work very well under some circumstances.
Like when the object is occluded, but the shadow is visible, it will still be rendered, and the “was recently rendered”-Node returns true.
Now it came down to two possible solutions:
- using the “Line Of Sights To”-Node (i have to test out, if that works the way i want)
- using linecast on different points of the target.
If anyone has other possible solutions to share, I’m all ears.
For what purpose?
Have you looked at occlusion culling?
Hi, if it is only event driven (so you’re not doing this on tick for several actors), then I don’t see too much problem with using line traces (in C++ you can use hundreds of line traces on tick without much of an impact on performance, so just doing a couple of hundreds line traces in one frame, shouldn’t be any issue).
It might be easiest (and since you’re using blueprints also most performant) to add a perception component to the player and setup the sight sense for it. Then when you launch the attack, get all actors that are currently perceived by the sight sense of that perception component (but keep in mind there that the sight sense of the perception component has a maximum number of line traces on tick which you can also change in the config files, so if you’re using it too much and it starts to update slower)
Otherwise you can also check for line of sight by hand. So first filter by dot product (all the actors behind the player can’t be visible), then maybe also filter by “was recently rendered” (if that returns false then it isn’t rendered) and lastly use line traces.