Maybe it will sound strange, but I’d like to know how can I make actor events based on whether they are in the whole field of view of my first-person camera and beyond it. I know how to use “line trace by channel”, but only how to bind it to a vector from my camera’s center.
So… is there any way I can trace all my camera’s view area?
Depending on the application, perhaps it’s enough to:
Does not need to be tick. You could query actors on click.
Other than that there is the dot product
and the camera frustum math. Or you can try the ham-fisted approach:
Did you look into dot product and the link I left?
The first step is to calculate the dot product:
-1 <> 0
is behind you, 0 <> 1
is in front of you.
Above, there is a 10 deg leeway just to show how things pop into view. This is not a complete thing, ofc. - just to demo what I meant.
You know the camera fov, you know the aspect ratio, you know the viewport size and you know the bounds of actor. You can check whether this value is inside or outside of the desired range.
Sorry, don’t have the actual math for frustum in my head, would need to google that.
But culling is exactly what the renderer does and the calculations have been done; query the target’s recently rendered state. Isn’t that enough? If it’s not, experiment with doing it manually like in the example above.
I imagined some kind of frustum area of my camera from the very beginning, but I just don’t know how to make it.
I imagined some kind of frustum area of my camera from the very beginning, but I just don’t know how to make it.
Yes, I’ll try these too. But can you explain what did you mean by “camera frustum math”? Something like “frustum culling”?
Well, I tried your method with dot product, but it looks like it doesn’t cover the whole area of my actor but only lower line.
I can clearly see it by moving my camera to it from up to down and from down to up:
“WasActorRecentlyRendered” does a nice job too, but sometimes it is not that precise. For example, It gets “true” when I’m staying with my back close to the actor, or when I’m staying front close, but looking straight down.
Tbh, I’m just trying to recreate these “if looked at by player camera” events from Layers Of Fear, so I’m experimenting with different methods to choose one that will get it closest to the original. There HAS to be a way, as LoF 2 was made on Unreal.
it doesn’t cover the whole area of my
actor
Ofc it does not. As mentioned above, this is using actor location, which is not the same as location + actor bounds - which would be a 3d volume.
- you could cheat around it by placing dummies at the edges.
- but you could also trace to the edge of the screen by rotating a vector, fov gives you the angle.
Any reason why you don’t want to use recently rendered? I may simply misunderstand how this is supposed to work, tbh.
I just experimented with dot product and found out that it just reacts on actor’s DefaultSceneRoot component. I guess that can bring some clarity to using these nodes.
You can have a look here for some alternatives:
Warning, scary snowmen.
Clarity, nah. It has nothing to do with components per se. You can feed it any world location you want. In UE4 the root component’s world loc happens to be reported as actor world location, that’s it.
Dot Product is not a UE4 thing. It needs a direction derived from a normalised world vector. You need to account for actor bounds.
Perhaps this will help visualise better what dot product spits out:
I see. A few days age you told me that I can “cheat” somehow and it sounded interesting.
but you could also trace to the edge of the screen by rotating a vector, fov gives you the angle.
You meant combining viewport XY with camera FOV Angle? Or can you explain?