playMaker

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

mikosd

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Random Pick GameObject/Prefab?
« on: October 03, 2016, 05: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: 4120
    • View Profile
    • jinxtergames
Re: Random Pick GameObject/Prefab?
« Reply #1 on: October 03, 2016, 05: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
    • View Profile
Re: Random Pick GameObject/Prefab?
« Reply #2 on: October 03, 2016, 06: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: 4120
    • View Profile
    • jinxtergames
Re: Random Pick GameObject/Prefab?
« Reply #3 on: October 04, 2016, 03: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
    • View Profile
Re: Random Pick GameObject/Prefab?
« Reply #4 on: October 04, 2016, 04:55:51 PM »
Thanks so much! will update in a bit.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4120
    • View Profile
    • jinxtergames
Re: Random Pick GameObject/Prefab?
« Reply #5 on: October 04, 2016, 11:06:33 PM »
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