How To Attach An Actor To Another Non-Persistent Actor's Specific Component?

Hi Guys,

Here is an example of what I mean:
I spawn two actors in a level, Actor A has a few components and it’s the independent one, Actor B also has a few components and is the one that will have to be attached to a component of Actor A.

There is an issue though, the component that Actor B needs to be attached to is (let’s say) a scene component (can be anything though) but there are 5 scene components with different names in Actor A.
Since the Actors are non-persistent, I cannot create a reference to the needed component.
I’ve tried setting up a reference in GameState and PlayerState but I could not find a way to fill the reference in. If I create a component reference variable in (e.g.) GameState and set the reference during play from Actor A, the reference remains empty, the only way was for me to have Actor A already in the scene (and therefore persistent) and set the reference manually before starting the game, which is not what I want.

Is there a way around this?

TL;DR
Let’s say I spawn Two Actors in a Level during play and I need to attach Actor B to a component of Actor A where said component is one of many, how could I do that? How can I find that component and reference it in Actor B so that it knows what to attach to?

I might be misunderstanding, but couldn’t you just cast to the actor you want to attach to and ‘get’ a reference to the component you want to attach it to?

Is it possible to cast to an Actor that does not exist until it gets spawned? (Keeping in mind that there may be hundreds of copies of said actor spawning ingame at any given time, so I should be able to pinpoint the one I’m referring to.)

No, you can’t cast to something that doesn’t exist. But at some point, you or the player must be choosing what instance you/they want to attach to. That is the moment to cast to it, in the instant that you’d like to attach.
It might be easier to understand what you’re looking to do if you could explain it in a less abstract way.

In Level Blueprint after one seconds on Begin Play I spawn 10 instances of Actor A between World x0 and x10.
At World x-1 Actor B is then spawned.

Actor A is made up of 3 scene components at relative z0, z1 and z3.

Actor B needs to be attached to the 3rd scene component (Scene2) of the 3rd spawned instance of Actor A upon pressing Enter.

But I have no Idea how to reference to that specific Actor A.

To try and get around this, I could try and use three box collision components instead of scene components on Actor A, maybe in some way I can use a OnClick event to set a component reference to GameState of, say, box2 (formerly scene2) to be ticked by Actor B so that it always knows where the reference rests. But I’ve tried setting a actor reference this way with no avail, the Actor A reference created in GameState will remain empty even if, from Actor A OnClick I cast to GameState and Set the reference to self.

I solved the issue by line tracing on the needed Actor and using the return hit to cast to it.