playMaker

Author Topic: Random Pick GameObject/Prefab?  (Read 3978 times)

mikosd

  • Playmaker Newbie
  • *
  • Posts: 7
Random Pick GameObject/Prefab?
« on: October 03, 2016, 08:13:23 PM »
Hi guys! Quick question. So I'm having problem making random pick gameobject/prefab.
 Basically what I wanna happen is when the game start it drops random game object in the scene.. Kinda like brick game as the best example.

I did try the action  "select random game object", yeah it gives me random game object everytime I start the game but it only choose one and do it over and over again.

Anyone knows how to do it? it would be a big help! Thanks so much!!!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Random Pick GameObject/Prefab?
« Reply #1 on: October 03, 2016, 08:32:36 PM »
Hi,
You can place the objects into an array and use "get random array" to select an object

mikosd

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Random Pick GameObject/Prefab?
« Reply #2 on: October 03, 2016, 09:24:02 PM »
Thanks so much!! hmm, do you have any screenshots or vid how "array get random works?" I set them up but looks like its not working. Prolly I did the process wrong.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Random Pick GameObject/Prefab?
« Reply #3 on: October 04, 2016, 06:50:41 AM »
Hi,
I will explain how to :

Create an array variable, chose 'Array Type' "Game Object"
set size to how many gameobject you want to add and press enter
Place each gameobject into an element.

on the 'Array Get Random' action select the array you made and make a gameobject variable to store the object.

Now you can do what you want with the stored object (create / move / destroy....)

mikosd

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Random Pick GameObject/Prefab?
« Reply #4 on: October 04, 2016, 07:55:51 PM »
Thanks so much! will update in a bit.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Random Pick GameObject/Prefab?
« Reply #5 on: October 05, 2016, 02:06:33 AM »
Hi,
I also made a custom action for the get random array which will also get the index number, if you want to remove the object or need the index position for other arrays.
It is called "Get Random Array Index" and is now on the Ecosystem