# How do I detect when an actor enters the camera?

**URL:** <https://forums.unrealengine.com/t/how-do-i-detect-when-an-actor-enters-the-camera/472648>\
**Category:** Cinematics & Media\
**Tags:** overlap-actors, unreal-engine, CPP, question\
**Created:** [October 9, 2020, 9:35am UTC](https://forums.unrealengine.com/t/how-do-i-detect-when-an-actor-enters-the-camera/472648 "2020-10-09T09:35:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_b67d0e66](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b67d0e66](https://forums.unrealengine.com/u/anonymous_user_b67d0e66)\
**Post date:** [October 9, 2020, 9:35am UTC](https://forums.unrealengine.com/t/how-do-i-detect-when-an-actor-enters-the-camera/472648/1 "2020-10-09T09:35:53Z")

</div>

What I’m currently doing:

The camera collision channel doesn’t seem to ever trigger for overlaps, so I made a custom camera component where a collision box is attached to it (this is a top-down game so the view won’t change in any significant way to warrant more complexity), sized to the current screen resolution.

While actors do get sensed in overlaps with this method, there are two problems I can’t seem to get around:

1. There is no way to view the collision box–it’s a UBoxComponent with `Hidden in game` unchecked, but it’s still hidden (no matter what size it is and how thick I make the lines). This makes it super hard to debug.
2. Things that are already overlapping with the volume on BeginPlay() don’t get the overlap enter/exit events. Even when I change its box extents during runtime with `bUpdateOverlaps = true`, there are still no events occuring. I have to manually scale up the extents by an arbitrary number during tick until it gets to the size I want, but that seems non performant.

Is there another way to go about this?

---

<div class="post-metadata">

**Author:** ![Evigmae](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/evigmae/32/1187349_2.png) [@Evigmae](https://forums.unrealengine.com/u/Evigmae)\
**Post date:** [October 13, 2020, 11:30pm UTC](https://forums.unrealengine.com/t/how-do-i-detect-when-an-actor-enters-the-camera/472648/2 "2020-10-13T23:30:17Z")

</div>

You can use the `DeprojectScreenPositionToWorld` method in `APlayerController` to find the 4 corners of your screen in-world.  
With that you can create a box and see if the actor’s location is inside that box.  
For that you have `IsPointInBox` from `UKismetMathLibrary`

You don’t need to test collision with this, just positions in the world.

---

<div class="post-metadata">

**Author:** ![DuneGames](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dunegames/32/538495_2.png) [@DuneGames](https://forums.unrealengine.com/u/DuneGames)\
**Post date:** [September 25, 2023, 8:08pm UTC](https://forums.unrealengine.com/t/how-do-i-detect-when-an-actor-enters-the-camera/472648/3 "2023-09-25T20:08:47Z")

</div>

I found Project World Location to Widget Position works best - if there’s something better I’m not sure.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/4/b/a4b3872d19d472fb60ba4a28f1d26a1cc7061542.png)
