playMaker

Author Topic: Instantiating random prefab's[SOLVED]  (Read 1290 times)

kinetiknz

  • Junior Playmaker
  • **
  • Posts: 85
    • View Profile
Instantiating random prefab's[SOLVED]
« on: January 17, 2015, 09: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?
« Last Edit: January 19, 2015, 12:48:19 AM by jeanfabre »

kinetiknz

  • Junior Playmaker
  • **
  • Posts: 85
    • View Profile
Re: Instantiating random prefab's
« Reply #1 on: January 17, 2015, 09: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..

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Instantiating random prefab's
« Reply #2 on: January 17, 2015, 09:32:07 PM »
Try Select Random Game Object where you can choose from prefabs, etc.

kinetiknz

  • Junior Playmaker
  • **
  • Posts: 85
    • View Profile
Re: Instantiating random prefab's
« Reply #3 on: January 17, 2015, 11:13:26 PM »
Thankyou. Worked a treat.