How Can I Call A Certain Instance Of An Actor In The Scene From A Character That Has Not Been Spawned?

I’m a beginner at using UE.
I have three instances of a Spline in the scene. Spline itself is an Actor.
I also have a Player Character that is not in the scene, but spawns after hitting Play on UE.
So, I want to cast into or just reference one of these instances based on an integer variable inside the code of Spline.
So, I create 3 Object References to Spline in my Player Character BP. If my character was in the scene, I could just select the corresponding Spline for each reference using Eye Drop icon and make it work, but my Player Character spawns after the game begins, and when I get to set Spline’s instance, it just doesn’t allow me to do it, saying “Editing this value in a Class Default Object is not allowed”.
I have already found a workaround for this by making a Class reference to Spline and then calling “Get All Actors Of Class With Tag” to find my desired instance, but I’ve heard that “Get All Actors” is rather expensive operation, so I want to find an optimized way of doing this.
My Spline References are all Exposed In Spawn and Instance Editable.

1 Like

Get actors for one spline is not expensive at all. In the node is not bad at all generally. It’s when people put it on tick, the problems start.

2 Likes

Well, that’s what I think I do as well.
That integer as I said, could change during the game, which means the selected Spline could be changed based on that.
Unless I find another way to check for that integer and change the selected Spline.

1 Like

Have the spline actor talk to the character instead, either directly or via an Interface.

Another, probably better question is why you need to hard reference spline actors. You could use Event Dispatchers to register events. Perhaps there’s no need for referencing anything in the player.

Or, if all that is needed are 3 references, just Get All and move on :innocent: That node is often abused indeed (as mentioned in the previous post) but it does exist for a reason. This sounds like a justified use case scenario to me.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.