Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: 4arrancho on December 16, 2014, 04:22:50 PM

Title: Get variables from random gameobject
Post by: 4arrancho 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?
Title: Re: Get variables from random gameobject
Post by: 4arrancho on January 11, 2015, 01:47:21 PM
bump
Title: Re: Get variables from random gameobject
Post by: jeanfabre 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