playMaker

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

kinetiknz

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

kinetiknz

  • Junior Playmaker
  • **
  • Posts: 85
Re: Instantiating random prefab's
« Reply #1 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..

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Instantiating random prefab's
« Reply #2 on: January 17, 2015, 11:32:07 PM »
Try Select Random Game Object where you can choose from prefabs, etc.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

kinetiknz

  • Junior Playmaker
  • **
  • Posts: 85
Re: Instantiating random prefab's
« Reply #3 on: January 18, 2015, 01:13:26 AM »
Thankyou. Worked a treat.