Spawn an actor of class with specific property

I have a number of BP actors which derive from mutual BP class. Each of this actors have unique ID (for purpose of this question let’s assume this is the only difference between them). How do I spawn actor with given ID.

For example I have 10 “Cube” BPs childed from “GenericCube” BP (which has integer variable named “ID”), each of “Cube” BPs “ID” variables are set to numbers from 1 to 10, unique for each of them and I need to spawn one, that has ID = 4. How do I do that?

Possible decition is to spawn all of them, put their references into array, find out which of them have desired ID, keep it’s reference and destroy others, or spawn them one by one, destroying them consiquently, until desired one is spawned, and then keep it. But it seems kind of excessive, especially if I there’s hundreds and thousands of IDs

As a Reference they are assigned as they are drawn - you can’t alter that without altering the engine.

But you can assign variable values On Spawn by exposing them

120564-exposed.png

As you spawn the actor, you can set the exposed variables.

120565-useexposed.png

][2]

So you can assign them an “ID” on spawn but you will need to cast to them to determine what that value is from another blueprint.

Cool, I didn’t knew that! Thanks.

But correct me if I’m wrong, in that case I don’t need any child BPs, just
“GenericCube”, which I would spawn, giving its spawned instances different properties (variable values)? For me that would work, I just want to know if I got that right.

Child BPs use fewer resources than duplicates of actor classes, but a single class with exposed variable takes even less.

It depends on how much detail you want to have in your spawner compared to how much you want in each child class (if any).

I rarely use any, preferring to keep as much as I can as far as control in a single place.

I’ts actually a kind of card game, each card has around 10 properties, they share common mesh, but have various textures (materials). There’ll be around 150 unique cards, but in game I plan to spawn simultaneously not more that 20 of them.

You can make a Structure with the data each card will have (type, image, penalty/bonus categories,etc) and load them all into an array.

Then spawn the cards from that array (randomly, removing them from the ‘deck’ array as they are taken out.

Using one blueprint to represent all of the cards and just changing the data it holds.

120638-cards_shown.jpg