How to check if an actor is within camera view, and account for occlusion?

I’ve been searching for ways for an actor to determine if they’re on the player’s screen, and execute logic based on that.

So far the information that’s gotten me the closest to my goal is within this post and this post. I tried methods like using the “Was Actor Recently Rendered” node and/or checking if the actor’s 2D screen space location is within the viewport’s size, but all of these only return false if the player is not looking in the actor’s direction. They’re still being rendered when the view is blocked.

The screenshots below are examples where I’d expect the object to not be rendered. Like around a corner:

Or behind a large object, like a cylinder:

I’ve looked at Epic’s documentation on occlusion culling, but clearly I still don’t understand what’s going on here. Is there anyone willing to help me out?

unreal has tools for this type of situation, they are in the AI part of the engine

like seeing, hearing stuff like that. is more advanced so you need to invest some time in figuring how they work.

in your case if you have an " AI Sight" module implemented you can react when an object is seen.

or you can just use planned level design. so if you know that the player will come from a certain direction, when it is able to see the hidden object, add some triggers at that location when the player reach that point

maybe you are over engineering this :slight_smile:

1 Like

The AIPerception component is great! I use it along with EQS for my enemy AI. I should explain in more detail what I’m trying to accomplish…

I have a Marketplace asset that creates outlines on actors, and it works perfectly well. In my game certain enemies will spawn with the outline activated, and it can be seen through walls to help the player determine their location. I would like for enemy actors to know when they’re in the player’s camera view, so that the outline can be disabled. The “see through walls” feature is optional and I may have to forego it in the long run, but first I’d like to try and get the “viewport check” part taken care of.

Here is a link to the outline asset for context.