I want occluded blueprints to not run code

Hi, my game is using a lot of interactable characters, in a small village, when characters are occluded the code is still running, so for performance purposes, I need to know when those are occluded.
Recently rendered, is not working when those are occluded, (I checked occlusion is working on GPU using freeze rendering) doing a line trace with 60 characters, is horrible in terms of performance, removing and loading is not an option neither cos you can see them almost at the same time, they are using LODs, so I am using this to improve performance cos I am reducing the ticks when Higher LODs are loaded but is not enough
I just saw that “LastRenderTimeOnScreen” works, but is not available on blueprint, any Idea of what I can do?

There is a “Was Actor Recently Rendered” node that might be what you want.


Not my area of expertise but I’ll try to chip in.

@miguline What if you run Pawn sensing in the camera owning pawn? It could be as ham-fisted as this pseudoscript:

NPCs do not execute expensive script unless they’ve been sensed.


There may be some nuances / considerations regarding the scene setup. You say a small village - what’s our PoV, though? You’d want to avoid a springarm as it’d offset PoV for an actor-attached component. Ideally, you’d have a camera Pawn and use that as a camera.

1 Like

I would like there is something like the function I mention “LastRenderTimeOnScreen”, but indeed you had a great Idea, I will create an actor attached to the camera position, to not do cast, I will create it on the characters, I won’t mark it as solution yet in case someone know other way but I will mark it as solution if not, thank you so much It was very helpful

1 Like