Dynamicly spawning pawns

Hopefully I can describe my issue clearly enough.
What I am trying to do is to spawn pawns on demand during runtime. The following section of a blueprint does the trick.

However it seems to me there must be a better way. I wish to spawn a version of the pawn (all with the same parent class) based on the input enumeration.

I tried:
image

However, in this case the spawn actor function insists I have an instigator. I don’t have one. I don’t even know why it is insisting I have one in this case. From what I have read it is really a way to find whatever spawned this pawn (like in the case of a projectile) for reference. Well, I’m not spawning projectiles or anything I care about in that fashion. These will be fully controlled by an observer (player) or from the outside simulation. Bear in mind the second image is where I quickly pasted my attempt. In the case that I tried it, I did have the control flow nodes hooked up.

So I put together the first image, but that will become kind of a pain if we get more aircraft types to spawn. I can’t help to think I am doing something wrong or that there is some other way to do this.

Any suggestions?

1 Like

can’t help to think I am doing something wrong

Nah, it’s not bad but might get awkward as the scope grows.

or that there is some other way to do this.

Consider the following:

It’s a Enumerator | Soft Class Reference map. Some good stuff on the Soft topic:


If you do not care about the classes being loaded, make it a regular class reference.

Thank you for your suggestion.
Yes, I would have probably eventually migrated to an enumeration rather than the literals in the select node.

I see, however, you made the current pawn as the instigator. For some reason I had not even considered that. I suppose I was stuck on the fact that without the connector to the spawn class I didn’t need one and suddenly I needed one with a selector node attached.

This should work.

I was under the impression you were already using enumeration for this:

Associating any enums with classes would boil down any number of choices to handful of nodes.

spawn pawns on demand during runtime

Does not need to be an enum - depends on what the demand is here. If we’re talking huge number of options, I’d probably opt for a Data Table instead and fetch data by Name.

Enums with 30+ fields are no fun.

Good luck!

Oh, I am. Just hadn’t put it into a map association.
Ah I see the confusion. I didn’t finish the sentence. I meant an enumeration in a map and left out the “in a map” part.

1 Like

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