Spawning scene actors from array

Hi, I’m trying to figure out how to spawn actors that I have in my scene from an array. They are various instances based on the same class but have some differences such as different textures. It’s a card game and I just want to spawn different random cards from a deck when it is clicked. I’ve played around with various nodes and connections but the whatever I do, ti always just spawns the class BP object.

26116-array_spawn.jpg

I’m a total noob in Unreal so I’m probably just missing something simple and was hoping you guys could help me out.

In the pic are some of the nodes I’ve been trying this with. Any help appreciated:

Hello !

I think you have assumed Actors/Blueprints = Prefabs. They, however, not.

Your blueprint is base class and when you spawn instances of base class - all of them will have basic properties.

There is a lot of different ways to modify this behaviour, for example you can modify “Construction script”, which is called whenever object is spawned in world:


Just setup behaviour you want to see in construction script and then spawn your cards as usual

Yes, one method would be to let the Card BP create itself as a random Card instead of spawning a Random card.

The other method would be to create a Card Base Class and from that, create your different Card as a Child Class. Then you could create an array of classes and spawn them, but i guess modifying the BaseClass on Spawn like zeOrb said is the better approach :smiley:

Hi ,

As far as i know, there is no possibility to spawn the same Actors by reference, cuz they are already exists.

What do you want to achieve by creating a copies of existing actors?

Best wishes,

Thank you for the tips zeOrb,

Yeah I assume all kinds of nonsense…as I said…noob :). Using the constructions script seems to make much more sense, I will try this instead.

Another related question: if I want to spawn the actors to predefined locations with different transforms, for example to TargetPoints in the scene, but I want them to spawn at different target points in some predefined order, would it make sense then to set the target points up in an array and connect the spawn transform to that in some way?

Another related question: if I want to spawn the actors to predefined locations with different transforms, for example to TargetPoints in the scene, but I want them to spawn at different target points in some predefined order, would it make sense then to set the target points up in an array and connect the spawn transform to that in some way?

Yes, you may do that in this way (see attached screen below)

Best wishes,

It’s completely okay - new engine, new rules etc :slight_smile:

It’s up to you - you can “hardcode” this points if you don’t plan to change them often or you can have array with target points and then use ForLoop with array if there a lot of points.

Also, if you enable Editable and Show 3D Widget in your Vector variable, you can manually drag this point in editor.

Thanks guys, much appreciated