playMaker

Author Topic: transferring variables between several FSM?[SOLVED]  (Read 2905 times)

Muminka

  • Playmaker Newbie
  • *
  • Posts: 5
transferring variables between several FSM?[SOLVED]
« on: December 01, 2013, 09:10:11 AM »
I am wondering if it is possible to transfer variables between several FSM.

I have a butterfly which idles at a certain point and shall fly to a new point as soon as a special flower is spawned. I don't get this problem solved with FSM because I can't make the flower tell the butterfly the new point to fly at.

I know the "send message" action which transfers a variable to a script which works fine already.
But it does not seem to work with other FSM - or does it? Google gave me no answer about it.

Global variables also do not fit my problem, because every object with a similar behavior reacts to them. (All butterflies are flying to the spawned flower.)

Is there any way to use "send message" or global variables in the way I want to? Or is there an alternative solution?
« Last Edit: December 09, 2013, 02:10:07 PM by jeanfabre »

phannDOTde

  • Full Member
  • ***
  • Posts: 237
    • Peter Hann .de
Re: transferring variables between several FSM?
« Reply #1 on: December 01, 2013, 10:45:26 AM »
You could to a Global Event sending like "Next Flower" to the certain Butterfly and attache the New Position or Object to Fly to with set Event Data/Get Event Info. When he arrives he should report the Flower then that he is there and so on.

Maybe isnt the best Way to structure the OverAll Behavoir. Another Way could be to Tag all aviable Butterflies and Use that Tag as a Pool. Every Butterfly aviable goes in that Pool and another Script just checks if someone with that Tag and removes him plus sends him to the new position with. When it arrives it add himself again to the "aviable Pool".

cheers
Peter

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: transferring variables between several FSM?
« Reply #2 on: December 02, 2013, 02:11:15 AM »
Hi,

 you should fire a global event and pass in that event your value, then any fsm willing to be noticed about this value change simply needs to implement an fsm using theta global event as a global transition.

 I do that all the time, it's very powerful. NOW, if the value if changing everyframe, not  a good idea... instead, prefer implement a registration system so that all interested FSM can access the value directly at the source using "Get Fsm xxx".

bye,

 Jean

Muminka

  • Playmaker Newbie
  • *
  • Posts: 5
Re: transferring variables between several FSM?
« Reply #3 on: December 04, 2013, 03:14:00 PM »
Thank you very much! The global message worked fine!  :D