Is an actor culled or not? (with occlusion culling)

Hi, how I can know an actor is culled or not? Is there a flag or something in UE4?
Or in another words. I want to know is an actor invisible on screen now.

Thanks.

you should be able to use the UPrimitiveComp’s LastRenderTimeOnScreen value, compared to World->GetTimeSeconds() with 0.2f tolerance

This will tell you if an actor has been occlusion culled or not.

For example with a character:

auto isVisible = GetWorld()->GetTimeSeconds() - character->GetMesh()->LastRenderTimeOnScreen <= 0.2f;

O, that is exactly i want!
Thanks a lot!!

Hey, bro, i have tested this. This method is broken, or maybe i do something wrong.

So, look this. When the actor is on screen, it shows true. Ok, this is good. Then i turn arond and the actor goes out from the screen, it shows that visibility = false. Good. But if the actor is into camera frustum, but completely behind the wall, it should to be false, but it shows true.

Maybe i do something wrong? Occlusion culling set as true in preferences. Maybe there is something else?

Or i can just use linetrace to determine visibility, but this is brute force method.

Thank you.

Oh, people

I have to use AIPerception to know if an actor visible or not!!!

AIPerception!!!

I will be glad if my experience will be useful for anybody, thanks.
I think the question may be closed.

1 Like

I see the behavior you describe if I use Actor::WasRecentlyRendered. But If I use PrimitiveComponent::LastRenderTimeOnScreen as shown above and do the comparison when the character goes behind walls, isVisible returns false. I am using 4.13.2.

Hm, its strange.
I am using 4.15
Exactly LastRenderedTimeOnSceen gives me this issue.
But thank you for helping me. I think its easier to use AIPreception.

Before this i have developed on Unity c#. When moving to Unreal i expected that UE c++ will be easy like unity c#. But it is not. And after some time of coding on UE c++ i decide to go on blueprints at all. C++ is more harder to develop, it takes mush more time, and there alot of unpredictable situations. And blueprints are very easy to understand and to use.

Yes! this works, thanks a lot!