Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: kinetiknz on January 17, 2015, 11:12:08 PM

Title: Instantiating random prefab's[SOLVED]
Post by: kinetiknz on January 17, 2015, 11:12:08 PM
Hi there, at a set time I am looking to create/instantiate a prefab based on a pool of prefabs I have created. They have the tag 'wave' on them and I am currently doing this>

1 - get position - spawn location position storage for later
2 - get random object - using the tag filter 'wave' and store it
3 - create stored object object at the location from 1

I think the problem is the get random object.. I'm assuming it only has access to the scene and not the project? I would rather not have all of the prefabs loaded into the scene and use tricks to activate them when needed.

Is there a clean workaround for instantiating random prefabs?
Title: Re: Instantiating random prefab's
Post by: kinetiknz on January 17, 2015, 11:15:35 PM
I just had an idea which may work, but is inelegant.

I could generate a random number and switch through to 10 nodes creating prefab's specifically.

This will probably work, but it means 20 branches for 20 prefabs..
Title: Re: Instantiating random prefab's
Post by: Lane on January 17, 2015, 11:32:07 PM
Try Select Random Game Object where you can choose from prefabs, etc.
Title: Re: Instantiating random prefab's
Post by: kinetiknz on January 18, 2015, 01:13:26 AM
Thankyou. Worked a treat.