Finding Actors

A How To Guide for Finding Actors in your Scenes in Unreal Engine 4.

Windows
MacOS
Linux
On this page

Once you start constructing your game and its levels, you may find that locating an individual Actor in your scene may be difficult. It is not uncommon to have hundreds of Actors in your scene ranging from level set pieces or geometry, to NPCs or enemies, to interactable objects or pick-ups and locating one Actor out of all those is like the old saying of "looking for a needle in a haystack".

You can however use the World Outliner to help narrow your search for an Actor in your scene (pictured below).

Actors1.png

In the image above, the World Outliner (right) represents all the Actors that are placed inside your level. Clicking on one of the Actors in the World Outliner highlights it inside the level viewport as well. You can sort the World Outliner by Actor Name or by Actor Type by clicking on the Actor or Type headers (you can change the secondary category from Type to other filters by clicking the down arrow in the Type Box).

With an Actor selected in the World Outliner, and while navigating inside the Level Viewport, pressing the F key will move the camera to the location of the Actor selected to Focus on it.

Refer to the World Outliner documentation for more information on locating an Actor in your scenes.

While finding an Actor in the Editor can be accomplished with the help of the World Outliner, how do you go about finding an Actor through Blueprints so that you may modify it in some way? This "How To" series will show you some ways in which you can search your scene for an Actor based on varying criteria at which point you can then access and modify it if you wish.

Implementation Guide

Project Setup

In this tutorial, you will find Actors in a level by using the Get All Actors of Class node. When this node is called it will retrieve all Actors in your level of the specified Class and place them in an Array. Then, from that Array, you can retrieve an Actor or Actors based on your filter criteria. You can then access the properties of the Actor(s) or modify them in some way based on the functionality you want to achieve.

  1. Begin by creating a New > Games > ThirdPerson > Blueprint Project With Starter Content, named FindingActors.

image alt text

  1. Navigate to Edit > Project Settings > Engine > Input > Bindings > Action Mappings, then click Add(+) to create a new action mapping named FindActorPressed, then set the key value to 1.

image alt text

Creating Blueprint FireEffect Actor

The Starter Content folder provides a completed FireEffect Actor that includes a Particle Component to represent the flame effect, and an Audio Component for the sound effects. This Actor will be used as the base Actor class to find from the Get All Actors of Class node.

  1. Navigate to Content > StarterContent > Blueprints, then drag an instance of Blueprint_Effect_Fire into the World.

image alt text

Third Person Character: Setting Up the FindingActor Pressed Event

  1. Navigate to the Content > ThirdPersonBp > Blueprints folder and double click the ThirdPersonCharacter to open its Class Defaults.

image alt text

  1. Right-click on the Event Graph, then from the Actions menu search for the FindActorPressed action key event.

image alt text

  1. From the FindActorPressed node Key Event, drag off from the Pressed pin, then from the Actions menu, search for the Get All Actors Of Class node.

image alt text

  1. Inside the Get All Actors of Class node, click the Actor Class, then from the drop-down select the Blueprint_Effect_Fire class.

image alt text

  1. Drag off from the Out Actors pin and in the Actions menu, search for ForEachLoop.

image alt text

  1. Drag off from the Execution pin of the Get All Actors Of Class node and plug it into the Exec pin of the For Each Loop node.

image alt text

  1. From the ForEachLoop node, drag off the Array Element pin, then in the Actions menu, search for Get P_Fire.

image alt text

  1. Drag off from the Array Element pin, then in the Actions menu, search for Get Fire Audio.

image alt text

  1. Drag off from the P Fire pin, then in the Actions menu search for the Deactivate node.

image alt text

  1. Drag off from the Fire Audio pin and connect it to the Target pin from the Deactivate node.

image alt text

  1. Click Compile and Save.

image alt text

Finished Blueprint

image alt text

End Result

  1. Navigate to the Toolbar and click Play(PIE).

image alt text

When pressing the numeric 1 key, you should notice the Fire effect particles will extinguish and the sound effects emitting from the audio component will no longer be heard.

image alt text

Get Specific Actors with Tag

You used the Get All Actors of Class node to get an Array of Actors of a specified Class. However, you can also filter the Array results based on different criteria to get specific Actors or a single Actor from the Array by using Tags on the Actor. As an example,

  1. Navigate to the Content > StarterContent > Blueprints and select Blueprint_Effect_Fire.

image alt text

  1. In the Details panel, navigate to the Tags section and click Add(+) to add a tag to the Actor.

image alt text

  1. In the 0 element field, enter "FindActorTag" into the text string.

image alt text

  1. Inside the MyCharacter Blueprint, drag off from the Array Element pin of the ForEachLoop and in the Actions menu search for Get Tags.

image alt text

  1. Drag off from the Tags pin, then in the Actions menu search for the Get node.

image alt text

Here we are "Getting" the Tag at Index 0 which we set as FindActorTag above.

  1. Right-click in the graph and in the Actions menu, search for the Branch node.

image alt text

  1. Drag off from the Condition pin of the Branch node and add an Actor Has Tag node.

image alt text

  1. Connect the out pin from the Get node to the Tag pin on the Actor Has Tag node.

image alt text

  1. Connect the Array Element pin of the ForEachLoop node to the Target pin on the Actor Has Tag node.

image alt text

  1. Drag off from the Array Element of the ForEachLoop pin twice to get P_Fire and Fire Audio nodes and connect them to a Deactivate node.

image alt text

  1. Click Compile and Save.

image alt text

  1. Select one of your Blueprint_FireEffect's from the Level viewport, then from the details panel navigate to the Tags variable, locate the FindActorTag field, open the drop-down menu, then select Delete to delete the tag variable.

image alt text

We are intentionally leaving one of the fire effects without a tag in order to demonstrate the functionality.

  1. Navigate to the Toolbar and Press Play(PIE).

image alt text

End Result

When pressing the numeric 1 key, you should notice all Bluprint_Fire_ Effect particles with the ActorsToFindTag are extinguished, while the fire effect without the tag remains.

image alt text

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss