Get reference to an actor placed in a level?

How do i reference an actor placed in the level (of type empty actor) so i can assign it as the owner of something else?

1 Like

You can use “get actors of class”. If you have just one, you can just take the array from it, use get node. If you have multiple, you can assign a tag to that specific actor and then use “get actors with tag” (not sure if this one is called like that). Or use loop with “has tag”.

2 Likes

Get all actors of class also works for multiple actors, but you have to connect it to a for each loop instead of a get node.

I had to share since this alternative works for me. If you’re trying to access one actor from another placed in the level. Basically you can add a variable in the blueprint of the first actor that is a public reference to an actor. Then you can use the eyedropper to select the second actor. This is good for chaining actions in your level.

MY SOLUTION - For anyone finding this later, I needed to automate the “Get all actor by class” but couldn’t reference class/actor by anything but class. So I added a tag to the actor and used “Get All Actors with Tag”, get array ref, 0 index, prosper!

In blueprint, if you want add reference node to object in level, just select the object in level, then you blueprint, right click to add the node.

1 Like

But if I want to add reference node in widget blueprint. How can I do?

1 Like

Just in case anyone was trying to do something similar to what I was…

I have an enum for my NPC that determines its type (Normal, Super, Ultra etc.) which is something I change when placing the NPC in the level. I was trying to code a system so that if something goes wrong during navigation (ie the NPC gets stuck) it will try to reposition the NPC 3 times, and if every attempt to reposition is unsuccessful, then it would spawn a replacement NPC and match its NPC type. The issue I was having is that I couldn’t just get the Enum because it would default to the one at the top of the list, not the one from the NPC placed in the world. Then I realized I could use BeginPlay to get the Enum value and promote this to a variable and this gets me the correct adjusted spawned value and not just the default value.