playMaker

Author Topic: Variables local to all FSMs under parent gameobject?  (Read 4098 times)

markinjapan

  • Full Member
  • ***
  • Posts: 103
Variables local to all FSMs under parent gameobject?
« on: August 15, 2012, 01:20:02 PM »
Just wondering something.

Sometimes I have 1 gameobject with many FSMs and I want to share a variable between them. I used to use global variables (so that all FSMs could access them) but it got very messy.

I now use local variables but I have to use 'Get FSM [variable]' in order to get a variable from one FSM to another. But this is a little messy because I have to use the Get FSM actions.

I was wondering if such a thing exists as a 'Gameobject variable'? They would be global to the parent gameobject only and any FSMs under that gameobject would be able to access any variables stored in any of the FSMs under the parent gameobject.

So not Global, not Local, a National variable? :)




jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Variables local to all FSMs under parent gameobject?
« Reply #1 on: August 15, 2012, 05:24:28 PM »
Hi,

 yes, this is something that I mentioned a long time ago, that would be really helping a lot actually. but I think that I would prefer the other way around, child of a gameObject could access variable exposed as being "gameObject variable".

gameObject A
   -- GameObject B

 GameObject B can access fsm variable from GameObject A declared as "gameObject variable"

 is that what you are after?


bye,

 Jean

markinjapan

  • Full Member
  • ***
  • Posts: 103
Re: Variables local to all FSMs under parent gameobject?
« Reply #2 on: August 16, 2012, 07:07:09 AM »
Hi,

I see what you mean, yes, that would work.

Mark

Andrew.Lukasik

  • Full Member
  • ***
  • Posts: 134
    • my twitter @andrewlukasik
Re: Variables local to all FSMs under parent gameobject?
« Reply #3 on: September 18, 2012, 02:59:34 PM »
I find this idea kind of appealing because I find myself creating prefabs with this kind of 'FSM trees' lately. Jean's version seems to be thought out. But we must have strong answer to question "what would it solve/improve? (rather than merely complicate)". Global variables kind of solve this (?)

My addition here is: Why not "prefab variable" (vars shared back and forth in one prefab)
This could be particularly interesting since Unite2012's presentations are proposing that prefabs will be closed objects in Hierarchy window

A.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Variables local to all FSMs under parent gameobject?
« Reply #4 on: September 19, 2012, 01:30:06 AM »
Hi

 I fear that Unity 4 prefabs will not work right away exposing an Fsm variable.. because Fsm variable are NOT regular variables like ones you create by scripts, they are embedded within a system that is permeable, so playmaker would have to somehow, IF technically possible, let the develop expose a Fsm Variable in a Prefab Tree.

 I personally very rarely use Global Variables, maybe one or two, but just for the sake of it. Using GLobal variables everywhere it in my opinion a bad design technic, a perfectly valid one, but not from a theoretically point of view. It is essential to think in OOP, or in encapsulation. if anything can access everything, this is causing trouble down the road always.

 I wish global variables would have been actually "protected" variable or something so that it is accessible by a bunch of fsm ( either via hierarchy, or develop decision), or something like that.

bye,

 Jean