Adding Character Child instances into an array

This is driving me nuts I’ve created:

245163-children.jpg

When I use:

it’s playable with random characters. But when I try to make an array so that the player always gets the right char. I have no Idea how to get it to work:

Why does this have to be so complicated? All I want to do is store 3 character actors in an array in a certain order. “Get all actors of class” isn’t usable as it changes the arrays order. I have no Idea how to do this and neither the docs nor googling the problem has brought me any further.

Those images are kinda confusing so just need to clarify a few things here. Where is the “selection” blueprints? How does a player select a character? When a character is selected are they then spawned into the world or are all available characters present in the world at the time the player is choosing them? Additionally, I think you are mixing up 2 different things in your code. “Get all actors of class” only finds actors CURRENTLY spawned in the level not actors that WILL be spawned later. So deleting the “level references” would cause a failure of that node to find any references. “Spawning” an actor dynamically is a completely different issue and if you are doing that I am not sure why you need these arrays to figure out which actor to spawn in the first place? Anyway, some clarification on game play would be helpful here then I am sure we can figure this out haha

I have a widget when the level starts: I currently I use an Int (Chosen Fly Int) to determine which char has been selected alt text

I have all 3 characters on the level and teleport the ones that aren’t used somewhere where you can’t see them. I don’t do this because I want to but this was the only way I got it to work. I’d rather spawn them that is much cleaner.

If you have a widget that pops up on level start, with 3 options for characters to choose from, why don’t you have the “button” for each character directly spawn that specific character into the world? Why bother with the other 2 unused characters and deal with teleporting them away from the player’s view? I just don’t really get this logic here. Seems like an overly complicated way to have a player “select” a character to play with.

Yes I agree but like I said that was the only way I got it to work. Also I want the player to be able to switch between the characters later. Maybe upon the death of one char the player gets another.

Here is the spawn script:

This is what happens:

What I’m trying to say is, have the widget spawn the selected player. On player death you can have an event from the player controller or game instance or some other higher level blueprint spawn a new character to then possess.

I’m so stupid I forgot to plug in the “in pawn”.

Here is the fixed version:

The choosing process still doesn’t work but spawning a single char works fine now.
I’ll fumble around with my int and arrays and if I don’t get that to work I’ll just use one Custom Event per button for the choosing process. I don’t want to have much code in the widget I might replace it with a level or some part of the map I design as a menu.

Thanks a lot! Sometimes just talking about something helps to find the problem. XD

Do you know a way to store Characters in an array that have not been spawned yet? Or is that not possible? I’ve created this:

But that somehow doesn’t work even though it should work.

Scratch that got it to work:

It was actually pretty easy:

Big thanks to Nebula Games Inc for the pointers!

Guess I couldn’t see the forest since there were too many trees XD

Hey,
I also want to call an array but didn’t understand how to use it.
I am using this code to spawn NPCs, but I want them to spawn with different skeletal meshes.