Best practice for finding a specific actor?

I’m working on a project where I have defined a Trigger Object, and a Action Object. The goal is to have the trigger object start a event inside the action object.
Now the problem I am running into is I need multiple trigger objects and multiple actor objects in the same level. My current idea is to build some sort of data structure inside the trigger that contains a list of all Triggers Objects names in a scene, and the names of the Action Objects they are connected to.
Using the name of the Trigger Object, I can then look up which Action Objects its connected to. From there, I can get all actors of class Action Object, and iterate though until I find the ones with the correct name.

This seems a bit backwards to me though, so I am wondering if there is a better method?

Name the action objects with tags, then on the trigger bp: get all actors of class with tag -for each loop -set the var or whatever you want to change -do the thing. The action could be a custom event inside the action object bp, that you call on the trigger, from the array element output of the for each loop node.

If they’re all spawned at start, I would reference them in the level blueprint, do makearray for them, then set the values into similar arrays in gamemode. That way you’re not iterating through every one, you’re just using the references.

If you’re spawning them then you can do something similar where you would just run the event and pass the reference of the object into the other so it can always tap back out.

The concept would be similar to in playercharacter having Q open a widget so you do create widget w/ an exposed variable of player character and tie a self reference from player character to that exposed pin on the create widget node. That way, player character can always just call - destroy InventoryWidget without looking through every one of them.

Right, you would want to do the base referencing in the level because an actor reference cannot be referenced even in the editor before the game knows about it, only an actor class can be referenced in the editor. The level blueprint is the only place you can reference directly from your map because it is the container for those items and thus know that if keys a-d are in the map, they exist and can be set into an array and then handed to the door in the map through the exposed variable.

Hi,

nor does there seem to be a way to
have every instance of the blueprint
have a unique reference.

click on the “eye” icon next to a blueprint variable. Then you can check expose on spawn and it will be exposed on spawn (your constructor in the trigger) and you can also set it inside the editor (e. g. create a variable of array of action objects inside your trigger and then populate that array inside the editor) or do it in the level blueprint as described in the answer above.

I appreciate the answer, but I am entirely unsure as to how using tags address any of my issues. I can already get a array of all the Action actors, the problem is with binding them to a specific Trigger Actor.

If we were dealing with pure code, ideally I would have a constructor in the trigger that takes the value(s) of the relevant Actions and pre populate it. Unfortunately there does not seem to be any way to add a non default constructor to a blueprint, nor does there seem to be a way to have every instance of the blueprint have a unique reference.

Appreciate the answer. Some clarification, the triggers and actions start prespawned.
The idea behind iterating is to allow me to find the reference to the relevant Action(s), and would be done in the constructor.

If we were dealing with pure code, ideally I would have a constructor in the trigger that takes the value(s) of the relevant Actions and pre populate it. Unfortunately there does not seem to be any way to add a non default constructor to a blueprint, nor does there seem to be a way to have every instance of the blueprint have a unique reference.

I was aware of public variables, but I did not think to use them in place of a constructor, so thank you for that.
I cannot find anywhere in the editor that would allow me to set the reference before hand, but I think doing that in the level begin/play event should work fine?
Again, thank you for that suggestion.