playMaker

Author Topic: Get variables from random gameobject  (Read 1767 times)

4arrancho

  • Playmaker Newbie
  • *
  • Posts: 27
Get variables from random gameobject
« on: December 16, 2014, 04:22:50 PM »
I have 5 gameobjects

each one have 3 childs with global variables with different names like this:

Player A
>global string A
>global int A1
>global int A2
Player B
>global string B
>global int B1
>global int B2
Player C
>global string C
>global int C1
>global int C2
Player D
>global string D
>global int D1
>global int D2
Player E
>global string E
>global int E1
>global int E2

Now in another FSM i added them to arraylist and pick a random gameobject from it.

Let's say it picked Player C...

Know, how do i get the variables from Player C?

4arrancho

  • Playmaker Newbie
  • *
  • Posts: 27
Re: Get variables from random gameobject
« Reply #1 on: January 11, 2015, 01:47:21 PM »
bump

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get variables from random gameobject
« Reply #2 on: January 12, 2015, 08:16:09 AM »
Hi,

 something is tricky here.

 global variables are by definition accessible by all. so in your case I think you should instead have an fsm  on each or your GO with variable "1" and "2" as regular variables, and then use "Get fsm XXX action".

 it's called interface in a way. each of your gameobject are assumed to have an fsm with an excact name and have expected variables too, then you know where you are at all time.

 in that particular setup, I don't knowhow you are going to solve this unless you have thee arrayList, with reference "A", "B" and "C" each having a string, and two ints. And then you know where you are again.

I strongly recommand solution 1 using interfaces. It's utterly powerful.

 Bye,

 Jean

 Bye,

 Jean