Direct Object Array Functions
Skip the For Each Loop and connect an object array straight to a function's Target pin.

In many cases, it’s necessary to iterate through an array in order to execute a function on each element. However, this isn’t always the case for object arrays. Impure functions native to the object can be called directly on the array by connecting it to the function’s Target pin, so there’s no need for an iterator.
For example, consider the task of destroying all actors stored in an actor array variable within Blueprints. Instead of using a For Each Loop to iterate through the array and calling Destroy Actor on each element, the actor array can be connected directly to the Target pin of Destroy Actor to achieve the same result. The node runs once per element.

Frequently asked questions
Here are some common questions regarding this tip.
How do you figure out which functions accept the object array input?
A function accepts an array on its Target pin when it’s impure, has no return value, and isn’t latent like Delay. For example, Set Actor Location returns a Boolean, so it won’t accept an actor array on its Target pin.
Thankfully, you don’t need to memorize that. Drag off an object array pin with Context Sensitive enabled, and the action menu lists the target’s member functions that qualify. Event dispatcher nodes, such as Bind Event and Call, accept an object array on their Target pin too.
Are there performance improvements when using this method?
No. When the Blueprint compiles, the node becomes the same loop a For Each Loop runs, so the work is identical.
When should I still use a For Each Loop?
Use a For Each Loop when you need the added flexibility and control it provides. For example, if you need to stop iterating early with For Each Loop with Break, read each element’s index, or perform some other logic on each element before or after calling the function.
Unreal Directive is free and ad-free.
If it saved you time, you can help keep it that way.

