# How can I trace camera's field of view area?

**URL:** <https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533>\
**Category:** Cinematics & Media\
**Tags:** debug-trace, unreal-engine, question\
**Created:** [October 4, 2021, 8:30pm UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533 "2021-10-04T20:30:27Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Falcognito](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Falcognito](https://forums.unrealengine.com/u/Falcognito)\
**Post date:** [October 4, 2021, 8:30pm UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/1 "2021-10-04T20:30:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 5, 2021, 8:03am UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/2 "2021-10-05T08:03:49Z")

</div>

Depending on the application, perhaps it’s enough to:

 ![349867-screenshot-3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/d/0/7d04fa55d5b251718cbfeb4ac38016c16e4ac1c0.png)

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/8/e/78e7f6c535883653b4ea392cc9d66cf0b876ff8f.gif)](https://gyazo.com/d5a96a804c2aaab91a925ca0ec834bed)

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:

> **[How to determine if an actor is on screen?](https://forums.unrealengine.com/questions/329980/how-to-determine-if-an-actor-is-on-screen.html)**
>
> What is a good method of determining if an actor is located on screen? Essentially when the player presses a button the game stops and they can select an enemy from an array to perform an action on. I'd like to remove any enemy that is not...

---

<div class="post-metadata">

**Author:** ![Falcognito](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Falcognito](https://forums.unrealengine.com/u/Falcognito)\
**Post date:** [October 5, 2021, 11:40am UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/3 "2021-10-05T11:40:56Z")

</div>

I imagined some kind of frustum area of my camera from the very beginning, but I just don’t know how to make it.

---

<div class="post-metadata">

**Author:** ![Falcognito](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Falcognito](https://forums.unrealengine.com/u/Falcognito)\
**Post date:** [October 5, 2021, 11:40am UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/4 "2021-10-05T11:40:56Z")

</div>

I imagined some kind of frustum area of my camera from the very beginning, but I just don’t know how to make it.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 5, 2021, 12:17pm UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/5 "2021-10-05T12:17:50Z")

</div>

Did you look into dot product and the link I left?

---

<div class="post-metadata">

**Author:** ![Falcognito](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Falcognito](https://forums.unrealengine.com/u/Falcognito)\
**Post date:** [October 5, 2021, 1:25pm UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/6 "2021-10-05T13:25:31Z")

</div>

Yes, I’ll try these too. But can you explain what did you mean by “camera frustum math”? Something like “frustum culling”?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 5, 2021, 2:26pm UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/7 "2021-10-05T14:26:47Z")

</div>

The first step is to calculate the dot product:

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/4/3/f43173a40c4d90aaffb22bf9a219159645780d7e.gif)](https://gyazo.com/4e45c88957323dd47deed1bb72864284)

`-1 <> 0` is behind you, `0 <> 1` is in front of you.

 ![349869-screenshot-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/4/6/b466387e54c2173e79edc644cdcb438adab8b43b.png)

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/3/e/53e4461c070bdfd1689b8ab0dfc933751ede17a5.gif)](https://gyazo.com/aeeb8a12c05c1e951992b5ff55c0c52f)

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.

---

<div class="post-metadata">

**Author:** ![Falcognito](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Falcognito](https://forums.unrealengine.com/u/Falcognito)\
**Post date:** [October 5, 2021, 7:08pm UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/8 "2021-10-05T19:08:48Z")

</div>

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:

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/6/7/667e35a7ff97856bd6c5baa58a5e55465dbce198.gif)](https://gyazo.com/4db0f7c0ec9ec142930485ba019a6516)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 5, 2021, 7:54pm UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/9 "2021-10-05T19:54:56Z")

</div>

> 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. 😑

---

<div class="post-metadata">

**Author:** ![Falcognito](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Falcognito](https://forums.unrealengine.com/u/Falcognito)\
**Post date:** [October 5, 2021, 8:14pm UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/10 "2021-10-05T20:14:22Z")

</div>

“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. 🙂

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 6, 2021, 9:43am UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/11 "2021-10-06T09:43:15Z")

</div>

You can have a look here for some alternatives:

> **[Weeping Angels effect](https://forums.unrealengine.com/questions/823301/weeping-angels-effect.html)**
>
> I’m trying to make a weeping angels effect for a character. It’s supposed to execute a blueprint when the player isn’t looking at it and stop when the player is looking at it, but just pausing so it will continue the blueprint when the player isn’t...

Warning, scary snowmen.

---

<div class="post-metadata">

**Author:** ![Falcognito](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Falcognito](https://forums.unrealengine.com/u/Falcognito)\
**Post date:** [October 6, 2021, 11:51am UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/12 "2021-10-06T11:51:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 6, 2021, 1:17pm UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/13 "2021-10-06T13:17:20Z")

</div>

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:

> [@How to create God of War targetting system?](https://forums.unrealengine.com/t/how-to-create-god-of-war-targetting-system/210302/2):
>
> [The Dot Product](https://en.wikipedia.org/wiki/Dot_product) of 2 directional vectors will be in range of -1 to 1. Anything that’s above 0 is in front of you, anything below 0 is behind (and every other value in between matters, too!) I grab all the actors around the player using a Sphere Overlap (as in the original suggestion) and loop through the elements of the array, checking my angles - Dot player’s forward and the direction to each target. For dot values greater than .5 I mark the target, and add that actor to the array…

---

<div class="post-metadata">

**Author:** ![Falcognito](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Falcognito](https://forums.unrealengine.com/u/Falcognito)\
**Post date:** [October 9, 2021, 8:17am UTC](https://forums.unrealengine.com/t/how-can-i-trace-cameras-field-of-view-area/489533/14 "2021-10-09T08:17:42Z")

</div>

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?
