playMaker

Author Topic: Exchange Postion Randomly  (Read 2451 times)

kaelcabral

  • Playmaker Newbie
  • *
  • Posts: 25
Exchange Postion Randomly
« on: August 08, 2013, 10:04:15 PM »
Hey All,
I have 4 obj in my scene and I want to them exchange position randomly.
But the obj can't be at the same position from another obj.

This what I have so far:

Thanks much in advance for any information

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Exchange Postion Randomly
« Reply #1 on: August 08, 2013, 11:53:43 PM »
Hmmm, I can think of a few ways to do it ... which is the easiest though?! Have you used Array maker before?

How I would do it with Array maker -
- Create an array and add the 4 Gameobjects (via actions)
- Create a state "Set_Position_01" that gets a random item from the array (one of the gameobjects) and then set its position to Position_01. Remove that selected gameobject from the array and then move to a second state.
- Create a state "Set_Position_02", get random item, set position, remove from array.
- Create a state "Set_Position_03", get random item, set position, remove from array.
- Create a state "Set position_04", get item at index 0, set position, remove from array.
- Move back to the first state to repeat (note the first state will re add the 4 Gameobjects)

kaelcabral

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Exchange Postion Randomly
« Reply #2 on: August 09, 2013, 02:00:03 AM »
Thanks for the fast reply!!
Never used array before.
I did got the script but I'm not sure if I'm doing right.
I created an empty obj than apply all theses.

Thanks so much again for the advice :o

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Exchange Postion Randomly
« Reply #3 on: August 09, 2013, 02:56:28 AM »
Np, looking at your screen shots .... I would say it doesn't work?!

for the Array List get random you will need to set the Gameobject as a variable and then in the set position use the variable not the gameobject. Also check to see if the gameObjects are being added to the array. :)

kaelcabral

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Exchange Postion Randomly
« Reply #4 on: August 09, 2013, 03:36:52 PM »
You're helping me a lot!! 8)
Array is great! you can do a lot things with this.

I think I almost there, but still some bugs. not sure why...