playMaker

Author Topic: [SOLVED] Passing values between FSM in the same object?  (Read 1406 times)

cmonroy

  • Playmaker Newbie
  • *
  • Posts: 34
    • View Profile
[SOLVED] Passing values between FSM in the same object?
« on: November 06, 2014, 08:34:54 PM »
I have an FSM to setup things to be used at a later time, but when I try to GetFSMFloat, the action does not return anything and end with an empty value.

For instance, I have several FSM that do things with the camera but need to know the height, distance and a few vectors and quaternions to perform its duty. If I declare these variables in each FSM and then need to change the height value, for instance, I'll have to do it in each one of them. But if I put the configurable values in one FSM, then all the others could poll these values unaided.

My guess is that the Configuration FSM and the others are running at the same time and therefore could be reading the values before they are updated. Is there a way to poll those values after they have been initializated?
« Last Edit: November 07, 2014, 02:15:56 AM by cmonroy »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14373
  • Official Playmaker Support
    • View Profile
Re: Passing values between FSM in the same object?
« Reply #1 on: November 06, 2014, 10:59:13 PM »
Hi,

 fsm variables are only locals unfortunatly, so using get/set FSM xxx is the way to go, and yes it means duplicating your variables in each fsm you want to use them. I too would like to see some ways to improve this, but I fear it would be at a great cost of mis usage and mis understanding.

 Right now, when I have to do this, I name my variables in a way that I know who's the master fsm variable and who's a slaved variable, this way when I look at an fsm I know I shoudl not rely on such and such variables because marked "slaved".

"my float - slaved" for example will do or "**my float", something you adhere and conform in your project and it will be good.

 Bye,

 Jean

cmonroy

  • Playmaker Newbie
  • *
  • Posts: 34
    • View Profile
Re: Passing values between FSM in the same object?
« Reply #2 on: November 07, 2014, 02:15:29 AM »
I recreated the local variables as global ones and now each FSM can read and write most of them, even if they belong to different objects. Using this approach to cache the axis inputs and their multipliers and dampening values does not work, as these have to be consumed at their very own FSM.

Thank you Jean.

>>>Update:

As a matter of fact, the problem is when you assign a global variable to a local action, if the names of the local and global variables are the same. At Design time, Playmaker allows you to read a global variable, say SpeedDampening, and store it to a local variable with the same name. At Run time, however, the reference to the global variable is lost and replaced with the local instance which, of course, does not contain nothing. :)
« Last Edit: November 07, 2014, 02:28:38 AM by cmonroy »