playMaker

Author Topic: Reading variables of clones [SOLVED]  (Read 7726 times)

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Reading variables of clones [SOLVED]
« Reply #15 on: February 21, 2014, 05:59:03 AM »
why would you use find gameobject or get owner action, when you can just store gameobject variable when you instantiate it?

maybe if you have more gameobjects to instantiate i guess?

redikann

  • Full Member
  • ***
  • Posts: 174
Re: Reading variables of clones [SOLVED]
« Reply #16 on: February 21, 2014, 08:15:19 AM »
I try not to use global variables, so it's easier to grab a local reference per Fsm because I wont be calling instantiate in every FSM.

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Reading variables of clones [SOLVED]
« Reply #17 on: February 21, 2014, 09:15:45 AM »
why you dont like global variables? i like them alot and i use them alot too...

you could also use get fsm gameobject

redikann

  • Full Member
  • ***
  • Posts: 174
Re: Reading variables of clones [SOLVED]
« Reply #18 on: February 21, 2014, 11:11:32 AM »
Well you could but you would have a chance of error if that FSM was deleted or renamed.
Global Variables have been buggy in the past with playmaker. I like to use them on variables that exist to present information to the player .

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Reading variables of clones [SOLVED]
« Reply #19 on: February 21, 2014, 02:08:56 PM »
well i it just happens to be, that i need to use "find gameobject" action... and it seems to not be working with clones... it wont detect either by name, or by tag...

basically what i need to do... i have a breaking lights on bus, and i need to activate/deactivate them... so yes i need to use find gameobject action... i will try "Get Owner"  action later if i can do anything with it...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Reading variables of clones [SOLVED]
« Reply #20 on: February 24, 2014, 08:55:49 AM »
Hi,

 Instead, I would create a fsm "BUS" likely on the gameobject root of this bus. and it would know the two brake lights gameobject ( two variables that you reference manually during editing time) and since this is in the same hierarchy, everything is cool, as a prefab I mean.

then it's easy to get their references at runtime, use GEt Fsm GameObject on the  "BUS FSM" itself,

the other way is to create a global variable called "BREAK LIGHT ON" and "BREAK LIGHT OFF" and broadcast that global event JUST to the childs of the bus ( Send Event action can do that), and then you don't even care about the actual gameobjects themselves, you just create an fsm that receives these global event son the breaking light themselves and done.

bye,

 Jean

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Reading variables of clones [SOLVED]
« Reply #21 on: February 24, 2014, 09:16:05 AM »
what i did was something similar, i created FSM's on these lights, and then i created global events for example:

Breaking lights on & Breaking lights off

and then what i do is, i send event, and use broadcast all, and that works...

i think i have pretty much everything solved out in regards to clones now... so yeh i aint too far from releasing the game :)