Get Actor Of Class / Get All Actors Of Class¶
At a glance
Lives in: Blueprint API / Actor; implemented by Gameplay Statics -
Get Actor Of Class returns: one existing actor reference, or None -
Get All Actors Of Class returns: an array, possibly empty -
Cost: both search the current world; Get All is explicitly slow when
many actors match -
Official docs: Get Actor Of Class
and Get All Actors Of Class
The one-minute version¶
- These nodes search the current world for actors that already exist. They do not spawn anything, load assets, or find Blueprint classes in the Content Browser.
Get Actor Of Classreturns the first matching actor the world iterator gives it. Do not treat "first" as nearest, newest, top of the Outliner, or stable design order.Get All Actors Of Classfills an array with every matching actor it finds. If none exist, the array is empty, notNone.- The class filter includes child classes. Asking for
Actoris almost always too broad; asking for your exact Blueprint class is the normal beginner case. - They are okay for one-time setup, prototypes, debug buttons, tiny levels, or "there is exactly one manager actor" patterns. They are the wrong habit for Tick, widget bindings, repeated overlap checks, or every projectile looking for every enemy.
- Prefer the reference Unreal already gave you: event pins, spawn return values, exposed variables, saved references, or purpose-built framework getters.
What they actually do¶
Both nodes are shortcuts on Gameplay Statics. Blueprint supplies a hidden
world context from the object running the graph, then the node walks the actor
list in that world and checks each actor's class.
pseudocode of the engine behavior - not engine source
function GetActorOfClass(WorldContext, ActorClass):
World = find the current world from WorldContext
if World is missing or ActorClass is empty:
return None
for Actor in World's actor list:
if Actor is ActorClass or a child class:
return Actor
return None
function GetAllActorsOfClass(WorldContext, ActorClass):
OutActors = []
World = find the current world from WorldContext
if World is missing or ActorClass is empty:
return OutActors
for Actor in World's actor list:
if Actor is ActorClass or a child class:
add Actor to OutActors
return OutActors
The output pin is an object reference. If you choose BP_Door as the class,
Blueprint gives you references that can be used as BP_Door references. The
runtime objects are still the actual placed or spawned door instances in the
level.
The nodes search the world that exists on the machine running the graph. In single-player that is boring. In multiplayer it matters:
- the server's world has the authoritative replicated actors;
- each client has its local world, including actors replicated to that client and actors spawned only on that client;
- a client-side search is not a server-side search, and it cannot find actors that do not exist on that client.
That is why these nodes are not multiplayer identity tools. If the question is
"all players in the match," use replicated PlayerState data or server-owned
logic, not a client-side world search.
When they fail (and what failure does)¶
Get Actor Of Class fails by returning None. Get All Actors Of Class fails
or finds nothing by returning an empty array.
Common causes:
- The Actor Class pin is empty.
Get Actor Of ClassreturnsNone;Get All Actors Of Classreturns an empty array. - No matching actor exists in this world yet. The actor may be in another level, not spawned yet, already destroyed, or only present on another network machine.
- You asked from the wrong timing. Construction Script, widget pre-setup, or early initialization can run before the runtime actor you expect is ready.
- You picked a parent class that is too broad. The node may find a valid actor that is not the specific instance you meant.
- You assumed ordering. "First" is an implementation result, not a design promise. A small level change can make a different actor come back first.
Failure has no side effects. These nodes do not create a delayed wait, bind an
event for later, print a warning, spawn the missing actor, or retry next frame.
If None or an empty array matters, branch on it yourself.
The cost and the real trap¶
The expensive part is not the blue node color. The expensive part is the search shape: the node has to walk actors in the world and check their class.
That cost is fine when you do it once in a small level:
BeginPlay
-> Get Actor Of Class (BP_GameplayDirector)
-> Store Director variable
It becomes a problem when multiplied:
50 enemies
* Event Tick at 60 frames per second
* Get All Actors Of Class (BP_PlayerProjectile)
= 3,000 world searches per second before your real logic starts
Even when the level is small enough that it "works," this habit hides the
actual relationship between objects. A door does not need to search the world
for the player every frame if an overlap event already handed it Other Actor.
A projectile does not need to search for enemies if the hit event handed it
Hit Actor. A widget should not search for the character every frame if it was
created with an owning player or given a reference during setup.
Use world searches when the question is genuinely "what already exists in the world?" Do not use them as a replacement for passing references.
The pattern everyone actually uses¶
Use Get Actor Of Class for a unique manager-like actor, and cache it:
BeginPlay
-> Get Actor Of Class (BP_ObjectiveDirector)
-> Is Valid
-> Promote to variable: ObjectiveDirector
Use Get All Actors Of Class for one-time setup over a small set:
BeginPlay
-> Get All Actors Of Class (BP_LightSwitch)
-> ForEachLoop
-> Bind each switch's dispatcher to this room controller
For interactions, prefer the reference from the event:
OnComponentBeginOverlap
-> Other Actor
-> Cast To BP_PlayerCharacter
-> Open Door
For spawned actors, prefer the return value:
Spawn Actor from Class (BP_Enemy)
-> Return Value
-> Store in ActiveEnemies array
For designer-authored references, expose a variable:
BP_Door has instance-editable variable RequiredKeyActor
Designer assigns BP_Key_01 in the Details panel
Door checks that reference directly instead of searching
The C++ twin, for the curious (our own example code):
void ARoomController::BeginPlay()
{
Super::BeginPlay();
TArray<AActor*> FoundSwitches;
UGameplayStatics::GetAllActorsOfClass(
this,
ATrainingLightSwitch::StaticClass(),
FoundSwitches);
for (AActor* Actor : FoundSwitches)
{
ATrainingLightSwitch* Switch = Cast<ATrainingLightSwitch>(Actor);
if (!IsValid(Switch))
{
continue;
}
Switch->OnPressed.AddDynamic(this, &ARoomController::HandleSwitch);
}
}
Lookalikes - which one do I want?¶
| Node or pattern | Returns | Use when |
|---|---|---|
| Get Actor Of Class | One matching actor, or None |
There should be exactly one relevant actor and you only need setup-time lookup. |
| Get All Actors Of Class | Array of matching actors, possibly empty | You need to initialize or inspect every actor of a class. |
| Get All Actors with Tag | Array filtered by actor tag | You need a designer tag filter, but it still searches the world. |
| Get All Actors with Interface | Array filtered by implemented interface | You need "anything that can receive this contract," but it still searches. |
| Get Player Character / Pawn / Controller | Player-slot references | You are asking about a local player, not arbitrary actors. |
| Event pins like Other Actor / Hit Actor | The actor involved in an event | You are reacting to overlap, hit, trace, or damage. Start here. |
| Spawn Actor Return Value | The actor you just spawned | You created it, so keep the reference immediately. |
| Instance-editable object variable | A designer-assigned reference | The level designer knows which actor this instance should talk to. |
| GameMode / GameState / PlayerState getters | Framework objects | You need framework state, especially player or match state. |
| Event Dispatcher / Interface | Communication path, not a search result | You want actors to announce changes instead of being polled. |
Rule of thumb: search once when you must discover; store or pass references when you already know.
Going deeper¶
- Get Player Character / Pawn / Controller - why player getters answer a different question than actor searches.
- Spawn Actor from Class - keep the Return Value instead of finding the actor again later.
- Is Valid - guard the
Nonecase fromGet Actor Of Classbefore you call into the result. - The frame: Tick, timers, and timelines - why repeated world searches become expensive when multiplied by frame rate.
- Construction Script vs BeginPlay - why runtime references usually belong in BeginPlay or later, not editor construction.
- Official docs: Get Actor Of Class, Get All Actors Of Class, UGameplayStatics, and UGameplayStatics::GetAllActorsOfClass.
- Engine source (requires engine access - we do not reproduce it here):
UGameplayStatics::GetActorOfClassandUGameplayStatics::GetAllActorsOfClassinEngine/Source/Runtime/Engine/Private/GameplayStatics.cpp; declarations inEngine/Source/Runtime/Engine/Classes/Kismet/GameplayStatics.h.