It always returns true even though the actor is far from being in the view
Hi Davision,
I just tested this in 4.12.5 3rd Person template and itâs working on my end. Here is what I did:
-
I created an actor class blueprint with a static mesh component
-
Then added the setup below to the âThirdPersonCharacterâ blueprint
-
When the box is in view (being rendered) it registers True, when the box is out of view for 1 second it registers False.
What results do you get with this setup?
Tried it with a simple blueprint that is just a physics box and there it works fine. My more complex blueprint gives me always true, this are the components:
Could you also post a screenshot of your event graph setup? Or if you prefer, feel free to just post the .uasset that I can test.
It tested it just like you did with a print in the event tick. But the target was self.
Iâve the very same issue in 4.12.5. I consistently get bad results with the blueprint node Was Recently Rendered as well as AActor::GetLastRenderTime.
I have the issue even with simple actor blueprints. It seems to yeild true as soon and as long as the camera is moving while the actor resides in the frustum.
Way to reproduce:
- Create a fresh project (I used the content example)
- Create an Actor blueprint, add a static mesh component (I used a cube)
- Put it out of view range into the map
- Handle tick, output message if object was recently rendered
Actor setup and event graph:
Actor placed behind a wall:
Output:
Hi Eamid,
This is because the âWas Recently Renderedâ node only takes into account the frustum for code based optimization purposes. It isnât the same as occlusion culling.
You can find it explained in a little more detail in this Forum post by Rama.
In 4.27 âWas Recently Renderedâ is always returning true. To test I made the same blueprint in 5.0ea2 and it works. Is this a bug that needs to be reported for 4.27?
Sorry, the function does work in 4.27, but for some reason when my game screen widget that shows my characterâs health and stuff is added to the viewport, it stops working. I canât figure out why this is happening because the WasRecentlyRender function seems to check the World for time passed. Which shouldnât have anything to with a widget.
I found the problem. I was using a render target for my minimap. When the Minimap Blueprint with the RenderTarget was spawned is was rendering the actor I was checking with WasRecentlyRender.
In case anyone has this issue, Iâll state my hacky wacky way of solving this âalways trueâ problem for character blueprints in 5.4.
For context, I am making a weeping angel AI enemy that stops when rendered in view. The default character blueprint I used for the AI in my main level was always returning true when running the âwas recently rendered nodeâ for the body mesh, so I did some tests with a standard cube actor separately. The cube behaved as normal when running the function, stating true when looking at it in first-person and rendered on-screen, and false when off-screen.
I therefore placed a REALLY small cube on top of my AI character blueprintâs head and started to check if the cube was recently rendered instead of the whole body mesh. Lo-and-behold, it works!
I know this doesnât necessarily fully get to the root issue, but for people on a time crunch I hope this helped.
Fixed, thanks for the lead @mpspence. All you need to do is make sure that the static mesh is not set to Moveable. If you change to mesh to either Stationary or Static then it will work as intended.
Edit: Sometimes Stationary doesnât work, revert to Static if needed.