# How to determine if an actor is on screen?

**URL:** <https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [November 7, 2015, 12:57am UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713 "2015-11-07T00:57:37Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_c5a5a3741](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_c5a5a3741](https://forums.unrealengine.com/u/anonymous_user_c5a5a3741)\
**Post date:** [November 7, 2015, 12:57am UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/1 "2015-11-07T00:57:37Z")

</div>

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 currently on screen from that array, or not put an off screen enemy in that array in the first place.

---

<div class="post-metadata">

**Author:** ![mkamradt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mkamradt](https://forums.unrealengine.com/u/mkamradt)\
**Post date:** [November 10, 2015, 3:06pm UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/2 "2015-11-10T15:06:53Z")

</div>

Every scene component holds an “Is Visible” bool that is updated during rendering. You could iterate over all your enemy actors and all their scene components to sort out those being visible. However this is probably a slow operation. Maybe you could try to improve performance by first using BoxOverlapComponents with a “bigger than screen” box to sort out those that are really far away and just iterate over the rest.

Marc

---

<div class="post-metadata">

**Author:** ![alperenakyuz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alperenakyuz](https://forums.unrealengine.com/u/alperenakyuz)\
**Post date:** [November 10, 2015, 4:21pm UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/3 "2015-11-10T16:21:47Z")

</div>

UMG widgets have functiona that can twll you if a certain point in the world is on the screen. You can use your actors locations and get that information. You can even check for more than one point on the same actor (the body maybe offscreen but the hands or weapons are on screen) by getting mesh socket (or bone) locations.

---

<div class="post-metadata">

**Author:** ![Sean\_Flint](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean\_Flint](https://forums.unrealengine.com/u/Sean_Flint)\
**Post date:** [November 10, 2015, 5:09pm UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/4 "2015-11-10T17:09:09Z")

</div>

Hello,

You can try to use this setup, which will check to see if the object in question is in view. If you’re trying to check for multiple objects, you can replace TestCube with a foreach loop that will run through each of the objects you’d like to check.

Here is the setup:

 ![112950-bp.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/e/a/dea3e81b6651ccd3de5773de7f3d5f4be80b6782.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_c5a5a3741](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_c5a5a3741](https://forums.unrealengine.com/u/anonymous_user_c5a5a3741)\
**Post date:** [November 11, 2015, 9:52pm UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/5 "2015-11-11T21:52:22Z")

</div>

That worked perfectly thank you very much.

---

<div class="post-metadata">

**Author:** ![gagallo7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gagallo7](https://forums.unrealengine.com/u/gagallo7)\
**Post date:** [February 6, 2017, 9:39pm UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/6 "2017-02-06T21:39:46Z")

</div>

If you want to check if an actor is visible at the moment, there are two downsides with this approach:

1. This blueprint checks only if the origin of the actor is within the screen, so it may not work with large actors, for example.
2. The actor may be occluded by others and it is still on screen, but, if one of the occluding actors is opaque, the actor in question will be invisible at that moment.

To solve each one downside, you could:

1. Treat the object as a box and check if at least one of the 8 vertices is within the screen, using the Sean’s blueprint as base and _GetActorBounds_ node.
2. Use the node _WasRecentlyRendered_ to check if the component was occluded or not.

---

<div class="post-metadata">

**Author:** ![Falconeyi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Falconeyi](https://forums.unrealengine.com/u/Falconeyi)\
**Post date:** [March 4, 2017, 2:34am UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/7 "2017-03-04T02:34:52Z")

</div>

could you show an example blueprint for problem 1? I’m not sure how to use GetActorBounds node here.

---

<div class="post-metadata">

**Author:** ![Hemlock](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hemlock](https://forums.unrealengine.com/u/Hemlock)\
**Post date:** [February 6, 2018, 4:33am UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/8 "2018-02-06T04:33:49Z")

</div>

how would i get the number of actors that are in the viewport?

---

<div class="post-metadata">

**Author:** ![Teknerd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Teknerd](https://forums.unrealengine.com/u/Teknerd)\
**Post date:** [December 15, 2018, 3:45pm UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/9 "2018-12-15T15:45:18Z")

</div>

This thread is a bit old and maybe some of my implementation wasn’t available at the time. Also, I should specify this is really only good for detecting one actor not multiples, but in my case that was exactly what I needed. I think this is a fairly efficient method and it is working beautifully for me. I am using a ray cast at a starting point away from my main pawn and then casting to a specific distance out to see if it hits an actor. Please excuse some of the blueprint look I had to squeeze it down to be able to fit in one image. I did all of this as a prelude to getting the highlighting of actors working, the first obvious step being to detect the actor in the view port. Please note this is currently rendering the ray cast line, you can eliminate this by setting the draw debug type to ‘None’.

Basically how it works is you call this as a function (I am doing it after a movement of the player controller) and it will get the currently controlled pawn, find the forward vector and cast a ray straight forward for a specified distance. The two multipliers after the ‘Get Forward Vector’ call is what controls these parameters. I could hook these values out to the function parameters in order to control the ray cast distance but I didn’t do it for testing. You have to have the collisions set up properly for your actors. In this case I used WorldDynamic to filter, so for this setup it wont register a static mesh like walls or doors, it will only detect actual actors. For this case, my actor collision preset was set to OverlapAllDynamic.

The last part of it is to store if an actor was hit and which one was hit. I then call a custom event after this function call to trigger another piece of code in the controller to process the hit.

 ![262465-raycastfunction.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/f/0/ef0f8a3c409d2e8d65fad88bc03f402eb40f7d3c.png)

---

<div class="post-metadata">

**Author:** ![pixhitt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@pixhitt](https://forums.unrealengine.com/u/pixhitt)\
**Post date:** [October 13, 2019, 4:51am UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/10 "2019-10-13T04:51:42Z")

</div>

Thanks works like a charm!

---

<div class="post-metadata">

**Author:** ![RexReality](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RexReality](https://forums.unrealengine.com/u/RexReality)\
**Post date:** [February 7, 2024, 4:27pm UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/11 "2024-02-07T16:27:15Z")

</div>

will this work for VR do you know?

---

<div class="post-metadata">

**Author:** ![EXODST](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exodst/32/1031732_2.png) [@EXODST](https://forums.unrealengine.com/u/EXODST)\
**Post date:** [September 15, 2024, 11:52pm UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/12 "2024-09-15T23:52:01Z")

</div>

Here is the code for anyone interested. [Is Mesh On Screen posted by EXODST | blueprintUE | PasteBin For Unreal Engine](https://blueprintue.com/blueprint/mrvk3nar/)

---

<div class="post-metadata">

**Author:** ![EXODST](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exodst/32/1031732_2.png) [@EXODST](https://forums.unrealengine.com/u/EXODST)\
**Post date:** [September 16, 2024, 11:03am UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/13 "2024-09-16T11:03:20Z")

</div>

I previously posted the blueprint and someone let me know two verts were the same and i have since updated it. Now it should work flawlessly. The idea is to check if any bounding vertices are on screen instead of checking just the origin. Hopefully someone finds this helpful 🙂

Vertex1 = BoundsMin  
Vertex2 = (BoundsMin X, BoundsMin Y, BoundsMax Z)  
Vertex3 = (BoundsMin X, BoundsMax Y, BoundsMin Z)  
Vertex4 = (BoundsMin X, BoundsMax Y, BoundsMax Z)  
Vertex5 = (BoundsMax X, BoundsMin Y, BoundsMin Z)  
Vertex6 = (BoundsMax X, BoundsMin Y, BoundsMax Z)  
Vertex7 = (BoundsMax X, BoundsMax Y, BoundsMin Z)  
Vertex8 = BoundsMax

BoundsMin = Origin-BoxExtent  
BoundsMax = Origin+BoxExtent

I would also like to add that it may be very useful to add to a blueprint function library to use across all of your blueprints.

---

<div class="post-metadata">

**Author:** ![Pinteco](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pinteco](https://forums.unrealengine.com/u/Pinteco)\
**Post date:** [February 1, 2025, 12:42am UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/14 "2025-02-01T00:42:59Z")

</div>

I would like to add that this doesn’t work well if you are 180 degrees away from the actor, to fix this it needs to add another boolean in the “AND” node. I will link to the post that mentions this and a picture of how it looks

 ![3f911d8ac402bd0c2eb94e34aef9a58997393cc7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/7/a/47a5705613b34c2a20a6d753233b8d17962b945d.png)

> [@"How To" Know if an actor is on Screen?](https://forums.unrealengine.com/t/how-to-know-if-an-actor-is-on-screen/18961/11):
>
> I used pretty much the same way of checking if an actor is on screen in my project (ue4.26). However, I noticed one strange thing (or maybe I just don’t understand this fully). When I’m turned 180° from the actor (or wherever in the range of some -+60° from that point), the values returned stop changing, and it may give a false impression that the projected actor is actually on screen. So I started printing the boolean being returned: it was true when actor is on screen, and offscreen, but false…

---

<div class="post-metadata">

**Author:** ![BJGames](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bjgames/32/879537_2.png) [@BJGames](https://forums.unrealengine.com/u/BJGames)\
**Post date:** [July 24, 2025, 6:02am UTC](https://forums.unrealengine.com/t/how-to-determine-if-an-actor-is-on-screen/337713/15 "2025-07-24T06:02:27Z")

</div>

THIS!  
Godsend my friend!  
Thankyou
