How to spawn random actor?

I just start learning Blueprint. Can someone help me on this? Thank you in advance.
I have 4 child actors inherited from a master actor. I am trying to spawn them in level. How can I spawn them each time picking a random one?


I have tried many ways. I know I can put all 4 child actors in level and create an array but this way, since each actor needs to set with a Lifespan and Destroy Actor when overlapping, this will create some subtle bugs even the PIE run seems okay.
I have tried put all 4 actors into a Struct. As you can see in my screencap. Is there a way randomly pick one actor class reference into the Spawn actor node?

1 Like

Make array out of those MemberVars and:

image

Or, instead of a struct with 4 members, create an array variable of actor class type and populate it:


Also, a Delay inside a Loop will not work. Consider using a looping Timer instead. As in, when triggered, this would spawn a random actor every 5 seconds and stop after 10 has been spawned:

1 Like

Thanks a lot! This works!
Didn’t know it can be this easy to fix!

1 Like

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