How to get all actors in level and get all functions of one of the actor

So, the idea is very straightforward:

  1. Get all actors in level (not specific), So [get all class with Tag], [get all class with interface] or [get all actor of class] are not fit for this occasion.

  2. After getting the actors, I want to pick one actor and get all it’s functions and events.

  3. Finally, I want to bind a button to trigger the function in Step 2

Anyone knows how to achieve this? Thanks in advance.

are you already use
node for each loop ?

I mean getting all actors of current level, which will include the Static Meshes, lights, and user create BP actors and such. So I don’t know where to use the For each loop node.

Hi theGreatDW

To access the properties/functions of an object, you need to know what the object type is so you can cast. This is where interfaces are particularly useful as you won’t need to cast to the object type and access the interface directly.

Here are a couple of suggestions:

  1. Create a base class that contains the functionality you want and then add an instance for each of the objects in the world and add the lights / meshes etc as children. The base class can then store a self-reference in an array somewhere (probably the GameMode would be best) so you can access all instances.
    Pros: No need for GetAllActors and is quite efficient
    Cons: Will require resetting up your scene

  2. Use an interface. Interfaces are extremely useful for what you are trying to achieve as you do not need to cast to access the internal functions.
    Pros: Can have custom outcomes for the same event calls on different objects.
    Cons: You have to implement the logic for event calls for each object.

  3. Use a custom component and attach it to the objects in the world you want to access. This way you can retrieve all the components and get their owners which will return the objects regardless of type.
    Pros: Easy setup
    Cons: You will run into the same issue of actually trying to access the functions / properties of their owners unless you know their type.

Good luck


Thanks for your kind reply, Alex.
I believe your answer would help a lot of people who finds this Q&A.
However, what I really want is get all actors without knowing there types. And I just found that Get all level actors node is exactly what I needed. Combine with a save game, I got all actor names with thier paths.
What’s next is how to iterate each actor’s functions. I will update this Q&A once I know how to do that.
And once again, thanks for your great answer.

Hi theGreatDW

What’s next is how to iterate each
actor’s functions.

You need to access the objects type in order to get their functions / properties etc. Once you have all your objects, you could loop through them and compare their class and then cast to it.

The solution you are trying to implement sounds like is extremely expensive and could drastically affect performance depending on how many actors are in the level.

Perhaps you can tell us what it is exactly you are trying to achieve and we could then suggest a better workflow alternative.

Good luck