Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Tack on December 10, 2014, 02:40:09 PM

Title: [SOLVED] Pick item randomly from group of prefabs to spawn in scene
Post by: Tack on December 10, 2014, 02:40:09 PM
Hello everyone!

I'm making a little game that requires a random object to spawn on click. I already have a good sized library of items to pick from to randomly spawn. My problem is that I am having trouble determining a way to use Playmaker to pick a random item from the library to spawn.

This is what I'm hoping to accomplish and what I've completed:
1.Click box to open (Completed)
2.Play opening animation and particle effect on open (Completed)
3.Pick item randomly from group of prefabs and spawn (what I'm hoping to accomplish)
4.Destroy item after a certain amount of time (Pretty sure I know how to do this)
5.Close box on click (Completed)

Thanks for your time!
Title: Re: Pick item randomly from group of prefabs to spawn in scene
Post by: Lane on December 10, 2014, 02:43:28 PM
Use Select Random Game Object action and list your objects, then use Create Object to spawn the chose random object, then use the Wait action to wait for x seconds, then use Destroy Self to destroy itself.
Title: Re: Pick item randomly from group of prefabs to spawn in scene
Post by: Tack on December 10, 2014, 02:48:50 PM
Wow thank you for the quick reply! I'll try this out as soon as I get home from work and let you know how it goes.
Title: Re: Pick item randomly from group of prefabs to spawn in scene
Post by: Tack on December 16, 2014, 05:57:27 PM
I forgot to reply back. It worked like a charm. Thank you very much!