In this blog post we’ll explore three important Blueprint nodes in Unreal Engine: “Get Actor of Class”, “Get All Actors of Class”, and “Get All Actors of Class with Tag”.
They basically do the same thing, which is to find an actor of a specific class, but there are some small differences that you should be aware of if you work in Unreal Engine.
Get Actor of Class
You can use the “Get Actor of Class” node in Unreal Engine to get any actor with a particular class. To do this, you simply need to choose the desired actor from the “Actor Class” dropdown menu.
The key difference when using this node is that it will only find the first Actor of the specified class in the world.
As a result, instead of an array, the return value will be an Actor Object Reference.
One issue with this node is that it can be difficult to predict which actor will be selected as the first one. However, typically it will be either the first or the last one in the list.
Get All Actors of Class
The “Get All Actors of Class” node works similarly to the previous one, but with one major difference: it will find all of the actors in the class, rather than just the first one.
To use this node, simply select the relevant actor from the “Actor Class” dropdown option. The “Out Actors” output will generate an array containing all actors of that specific class.
If you’re unfamiliar with arrays, think of them as a list of all the actors who will be selected. They allow you to efficiently store, search and access large amounts of data. You can read more about arrays, array nodes, and how to work with them in the Unreal Engine Documentation.
Should I use Get All Actors of Class or Cast to?
This node works similarly to the “Cast to…” node in that it allows you to access a Blueprint of your choice.
The main difference is that it will not select a single blueprint actor. Instead, Get All Actors of Class will obtain every actor of that specified class in the world. Imagine you’ve used a Blueprint on 50 enemies, this will select them all. Also you don’t need to know the object’s wildcard.
When using the “Get all actors of class” node, be cautious because it can cause latency issues in the game. This method searches for all actors in the current level, not just the one you want to cast to, which can slow down your game.
It’s better to use this node only when necessary and not too many times. It’s best for a one-time line of code, such as “Event Beginplay,” or a custom event that occurs only once or occasionally.
If possible, it’s best to use a cast to a node. Using “get all actors of class” too frequently can slow down your game, so use it in moderation.
Just keep in mind to avoid using this 3 Blueprints nodes on tick, and keep it within a loop or a specific section of your code. That way, it won’t be called again and again, slowing down your game.
You can also access any variables or components in the blueprint actor by connecting a “Get (a copy)” node to the Array output.
Get All Actors of Class with Tag
Get All Actors of Class with Tag is a node that falls between the other two nodes and can be used in combination with them.
This node selects all actors of a specific class, but only those with the specified tag.
You can add a tag to a Blueprint by searching for “Tags” in the Details Panel and clicking the “+” button.
Now this node will only select the Sliding Door with the Tag “GameDevEXP” from all the Sliding Doors in the outliner. Be sure to write exactly the same tag in the “Tag” input of the “Get All Actors of Class with Tag” node.
Hope This Helps! Keep On Creating!