# Perform Frustum Check

**URL:** <https://forums.unrealengine.com/t/perform-frustum-check/287524>\
**Category:** Cinematics & Media\
**Tags:** culling, visibility, unreal-engine, question\
**Created:** [July 6, 2014, 12:42pm UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524 "2014-07-06T12:42:30Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maddius](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maddius](https://forums.unrealengine.com/u/Maddius)\
**Post date:** [July 6, 2014, 12:42pm UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/1 "2014-07-06T12:42:30Z")

</div>

Hey,

What’s the best way to use the cameras frustum to check the visibility of a set of actors? Or points etc?

Been looking around but not finding anything that useful.

Thanks

---

<div class="post-metadata">

**Author:** ![Maddius](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maddius](https://forums.unrealengine.com/u/Maddius)\
**Post date:** [July 9, 2014, 9:05am UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/2 "2014-07-09T09:05:02Z")

</div>

Shameless bump!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_7a9aff171](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_7a9aff171](https://forums.unrealengine.com/u/anonymous_user_7a9aff171)\
**Post date:** [July 9, 2014, 2:58pm UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/3 "2014-07-09T14:58:56Z")

</div>

Sorry for being so obvious, but you might try tracing from each actor position to your POV (camera position), then checking if the trace was unsuccessful (nothing occludes the visibility) and it lays within the frustum cone. This is an ugly hack, I might guess, but I am not familiar with Unreal’s graphical pipeline.  
If you stick to Tracing, Rama has this covered in a tutorial: [https://wiki.unrealengine.com/Trace\_Functions](https://wiki.unrealengine.com/Trace_Functions)

---

<div class="post-metadata">

**Author:** ![Maddius](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maddius](https://forums.unrealengine.com/u/Maddius)\
**Post date:** [July 9, 2014, 3:39pm UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/4 "2014-07-09T15:39:05Z")

</div>

Thanks for the info, the trace approach is an option, but all I really care about is whether or not the actors bounds are inside, intersecting or outside of the six planes of the frustum, so even if there is something in the way I’d like to know the result of that check.

You’d need to do at least two traces per actor as well since I’d need to trace to the min/max of their bounding box.

Is there anyway to actually get the planes of the camera frustum? Can just do a simple point plane check.

Will take another look when I can.

---

<div class="post-metadata">

**Author:** ![Maddius](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maddius](https://forums.unrealengine.com/u/Maddius)\
**Post date:** [July 14, 2014, 10:51am UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/5 "2014-07-14T10:51:11Z")

</div>

Haven’t tried it yet, but I am guessing these functions are what I want:

> **[GetViewFrustumBounds](https://docs.unrealengine.com/5.0/en-US/API/Runtime/Engine/GetViewFrustumBounds/2/)**
>
> Creates a convex volume bounding the view frustum for a view-projection matrix.

> **[GetViewFrustumBounds](https://docs.unrealengine.com/5.0/en-US/API/Runtime/Engine/GetViewFrustumBounds/1/)**
>
> Creates a convex volume bounding the view frustum for a view-projection matrix.

Will check it out, but think that’ll do it, cheers.

---

<div class="post-metadata">

**Author:** ![TooManyCrashes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TooManyCrashes](https://forums.unrealengine.com/u/TooManyCrashes)\
**Post date:** [April 7, 2015, 6:57pm UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/6 "2015-04-07T18:57:31Z")

</div>

You can do it like this:

```
bool IsInFrustum( AActor* Actor)
{
	ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController();
	if (LocalPlayer != nullptr && LocalPlayer->ViewportClient != nullptr && LocalPlayer->ViewportClient->Viewport)
	{
		FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(
			LocalPlayer->ViewportClient->Viewport,
			GetWorld()->Scene,
			LocalPlayer->ViewportClient->EngineShowFlags)
			.SetRealtimeUpdate(true));

		FVector ViewLocation;
		FRotator ViewRotation;
		FSceneView* SceneView = LocalPlayer->CalcSceneView(&ViewFamily, ViewLocation, ViewRotation, LocalPlayer->ViewportClient->Viewport);
		if (SceneView != nullptr)
		{
			return SceneView->ViewFrustum.IntersectSphere(
						Actor->GetActorLocation(), Actor->GetSimpleCollisionRadius());
		}			 
	}

    return false
}
```

---

<div class="post-metadata">

**Author:** ![EnOnE\_Masta](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/enone_masta/32/995640_2.png) [@EnOnE\_Masta](https://forums.unrealengine.com/u/EnOnE_Masta)\
**Post date:** [July 9, 2015, 9:59am UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/7 "2015-07-09T09:59:05Z")

</div>

works perfectly 😃

---

<div class="post-metadata">

**Author:** ![Hitsugen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hitsugen](https://forums.unrealengine.com/u/Hitsugen)\
**Post date:** [March 13, 2016, 11:01am UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/8 "2016-03-13T11:01:56Z")

</div>

Amazing. This worked perfectly

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_913c51ed](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_913c51ed](https://forums.unrealengine.com/u/anonymous_user_913c51ed)\
**Post date:** [December 21, 2016, 9:29am UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/9 "2016-12-21T09:29:28Z")

</div>

Have a look at “WasRecentlyRendered” … it may help.

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/6/a/76a069d63a8bb7f2a468a455a7f7d6a22ce8a2c8.jpeg "WTF Is? Was Recently Rendered in Unreal Engine 4 ( UE4 )") ](https://www.youtube.com/watch?v=0HNjgxyk99I)

---

<div class="post-metadata">

**Author:** ![Shmoopy1701](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shmoopy1701/32/1194536_2.png) [@Shmoopy1701](https://forums.unrealengine.com/u/Shmoopy1701)\
**Post date:** [October 22, 2018, 11:25pm UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/10 "2018-10-22T23:25:57Z")

</div>

double plus upvote

---

<div class="post-metadata">

**Author:** ![troydSPAMBOT3000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@troydSPAMBOT3000](https://forums.unrealengine.com/u/troydSPAMBOT3000)\
**Post date:** [November 26, 2018, 3:13pm UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/11 "2018-11-26T15:13:06Z")

</div>

I’d love to see a Blueprint solution of the code above if anyone is up to it…

---

<div class="post-metadata">

**Author:** ![Tanoran](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tanoran](https://forums.unrealengine.com/u/Tanoran)\
**Post date:** [October 28, 2019, 6:19pm UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/12 "2019-10-28T18:19:03Z")

</div>

What setup/includes are needed for this to work? VS flags LocalPlayer as an incomplete class type (which I think is due to a missing include), among other errors

---

<div class="post-metadata">

**Author:** ![lezard1999](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lezard1999](https://forums.unrealengine.com/u/lezard1999)\
**Post date:** [October 16, 2022, 2:52am UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/13 "2022-10-16T02:52:58Z")

</div>

Sir, could you give me a blueprint’s version about this method?  
Rellay need this one now 😂

---

<div class="post-metadata">

**Author:** ![lvl1s](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lvl1s](https://forums.unrealengine.com/u/lvl1s)\
**Post date:** [June 22, 2023, 11:12am UTC](https://forums.unrealengine.com/t/perform-frustum-check/287524/14 "2023-06-22T11:12:32Z")

</div>

![ba63499c2a1794af2be78a0fb087617f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/a/4/3a48feae06a2f2a6626a5349dc2cb88a89123116.png)  
 ![caedfa2193911036555229f387b7c599](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/9/5/a9520f84e9026b2ca73c89e7e05bc2349b346e2e.png)

For future people.  
This checks if a point is within a camera’s frustum using only blueprints.  
Here is an example of it stacked within a system to choose the most optimal cctv camera.

[https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/a/4/8a436905ae366d03a255d10b058382266f28bfa8.mp4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/a/4/8a436905ae366d03a255d10b058382266f28bfa8.mp4)
  

[https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/8/a18d897a170a006973e2dacaa0e36d294d34a354.mp4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/8/a18d897a170a006973e2dacaa0e36d294d34a354.mp4)

1. Each camera checks if each bone’s location is in its frustum.
2. Each point in its frustum get’s line traced too.
3. Camera with most visible points is chosen as optimal.  
…3.1. If 2 Cameras have the same amount of visible points, the one with the closest visible point wins.  
…3.2 If no camera is optimal then player camera is chosen
