# Get all actors in distance ...?

**URL:** <https://forums.unrealengine.com/t/get-all-actors-in-distance/280516>\
**Category:** World Creation\
**Tags:** Destroy, distance, unreal-engine, Array, Blueprint, question\
**Created:** [April 13, 2014, 7:30pm UTC](https://forums.unrealengine.com/t/get-all-actors-in-distance/280516 "2014-04-13T19:30:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cence](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Cence](https://forums.unrealengine.com/u/Cence)\
**Post date:** [April 13, 2014, 7:30pm UTC](https://forums.unrealengine.com/t/get-all-actors-in-distance/280516/1 "2014-04-13T19:30:16Z")

</div>

Hello there,

Is it possible to get an array / list of all actors within a specified distance from the pawn using blueprints?

Let’s say when an event triggers I have to destroy ALL actors (static meshes, lights, particle effects etc.) that are 10.000 units around the pawn. How about doing that?

Thanks for reading!

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [April 13, 2014, 7:43pm UTC](https://forums.unrealengine.com/t/get-all-actors-in-distance/280516/2 "2014-04-13T19:43:29Z")

</div>

#For Each Loop

Use the ForEach Loop!

Specify AActor as the class

and then do a distance check, comparing each actor to your source actor / player unit.

🙂

Rama

---

<div class="post-metadata">

**Author:** ![Steve\_Allison](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Steve\_Allison](https://forums.unrealengine.com/u/Steve_Allison)\
**Post date:** [April 13, 2014, 9:22pm UTC](https://forums.unrealengine.com/t/get-all-actors-in-distance/280516/3 "2014-04-13T21:22:29Z")

</div>

Hey Cence,

For a blueprint, you can use the **Get All Actors of Class** node to get all actors of a particular class (including just Actor) and then use that Array with a **ForEachLoop** as Rama mentions. In the loop, you can use the following setup to do a distance comparison and then execute whatever additional code you want after the Branch:

 ![4006-actordistances.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/6/2/862f836d6d491fb226ca43bf2b76d0cab9e07313.png)

Hope this gets you going in the right direction!

---

<div class="post-metadata">

**Author:** ![Cence](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Cence](https://forums.unrealengine.com/u/Cence)\
**Post date:** [April 14, 2014, 10:06am UTC](https://forums.unrealengine.com/t/get-all-actors-in-distance/280516/4 "2014-04-14T10:06:57Z")

</div>

Exactly what I was looking for!

---

<div class="post-metadata">

**Author:** ![Anonymous\_e5d5c0bf7d300728867097ff79906dbe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_e5d5c0bf7d300728867097ff79906dbe](https://forums.unrealengine.com/u/Anonymous_e5d5c0bf7d300728867097ff79906dbe)\
**Post date:** [July 25, 2017, 8:26am UTC](https://forums.unrealengine.com/t/get-all-actors-in-distance/280516/5 "2017-07-25T08:26:27Z")

</div>

@Steve Allison  
Isn’t there something nicer in UE4 ?  
I mean a native function that can query a scene graph and make it faster ?

---

<div class="post-metadata">

**Author:** ![Joshua\_NZ](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/joshua_nz/32/918677_2.png) [@Joshua\_NZ](https://forums.unrealengine.com/u/Joshua_NZ)\
**Post date:** [July 26, 2017, 3:13am UTC](https://forums.unrealengine.com/t/get-all-actors-in-distance/280516/6 "2017-07-26T03:13:40Z")

</div>

Hi,

The easiest way to do this is using a MultiSphereTrace. Put the player location in start & end and then add a radius.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![ProspectVR1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ProspectVR1](https://forums.unrealengine.com/u/ProspectVR1)\
**Post date:** [November 13, 2022, 9:17pm UTC](https://forums.unrealengine.com/t/get-all-actors-in-distance/280516/7 "2022-11-13T21:17:06Z")

</div>

Straightforward. Love It!

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [November 14, 2022, 7:00am UTC](https://forums.unrealengine.com/t/get-all-actors-in-distance/280516/8 "2022-11-14T07:00:51Z")

</div>

Instead of tracing, or a foor loop for all actors of class…

A proper (best practice) would be to add a gameplay tag to the actors when they spawn in, then loop the actors with that game-play tag to check a distance.

> **[Get All Actors with Tag](https://docs.unrealengine.com/4.26/en-US/BlueprintAPI/Utilities/GetAllActorswithTag/)**
>
> Get All Actors with Tag

Tags are accessible via the string array variable Tags.  
Though, you may need to edit the actor’s class in CPP to make the variable available, this I do not recall…

The loop _should_ be less expensive than a multi trace - when dealing with high number of actors/items that react to the trace.
