playMaker

Author Topic: Set Fsm * Bug [FIXED]  (Read 3055 times)

bkups2003

  • Playmaker Newbie
  • *
  • Posts: 49
Set Fsm * Bug [FIXED]
« on: June 30, 2014, 02:10:57 PM »
Ok so i'm having some problems with the Set FSM whatever actions. 99% of the time they work fine except in the case i have below:

I have a Gameobject with 12 FSMs that are used for translating objects around. They sit idle until another FSM decides how many of those it needs and sends events to get some of those 12 FSMs to do something. So here's the setup and the problem:

I will int add 1 and convert to string so it gets the next FSMs name. Then it sends to that FSM with that variable string name (ie.1,2,3 etc. etc.). Problem is, even though the int adds, and it goes to string fine, every Set FSM Gameobject/int/whatever will send to the first FSM that the string referred to. As if the String had never changed.

So anyway, after the SET FSM whatever actions, the next state has a send event that also sends to that string. That works perfectly and the FSM that the string refers to will recieve the event fine. So i end up with lots of FSMs that have recieved the events send to them, but never ever recieve the variables that were ment to be set before the event was sent. However the first FSM will be set again and again. Asif the string never changed.

I hope someone can help with this. I'm not sure if having each of those 12 FSMs use FSM get is quite feasable.

Thanks.

Edit: I made a quick example and attached it. Should be pretty self explanatory.
« Last Edit: August 03, 2014, 03:09:16 PM by Alex Chouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Fsm * Bug
« Reply #1 on: July 01, 2014, 06:36:02 AM »
Hi,

 I am not sure I follow 100% your process, I am confused wether it's the event data you don't get or the "set Fsm XXX" that is causing trouble. Typically, you need to be aware that the event data must be read as soon as you receive the event, because for a given fsm, there can only one event data at a time, it doesn't stack up basically, so if you are firing mayn events at the same time, it's likely the trouble, and you shoudl refactor this to avoid this race condition. Typically, I strongly suggest you use ArrayMaker ( you know it right?) and store your data on a "manager" referencing your data in a safe and traceable manner.

Bye,

 Jean


bkups2003

  • Playmaker Newbie
  • *
  • Posts: 49
Re: Set Fsm * Bug
« Reply #2 on: July 01, 2014, 10:18:58 PM »
I guess i explained quite poorly. Well, i'll try to explain the problem simpler.

I have 2 Gameobjects. The 1st has an FSM that does the stuff below and the second has 5 FSMS with a reference of 0,1,2,3,4 and they just sit idle but have a string variable with nothing in it.

Here's what's going on in the first gameobject:
There are 2 variables:
a STRING and an INT. INT==0.

Int to String,
Set FSM String: The second gameobject with reference STRING has its string set to STRING.
Int++

Then loop around and do it again. So in theory, The second gameobject's FSM reference "0" should have a string set to "0", FSM of reference "1" should have a string set to "1", "2" to "2" etc.

This never happens. The first FSM reference "0"s STRING will change each time. The other FSMs ("1","2","3", etc.) STRING never gets set.

So i thought, "maybe my STRING reference has a problem and it's just setting the first FSMs variable because of that. So i threw in a "Send Event" action to see if it would send an event to the right FSM. In the action, i set the gameobject to the second one, just like before, and the reference to STRING. This worked fine. Each loop would send an event to the different FSM of the second game object. They would only recieve their own event.

So i came to the conclusion that when "Set FSM String" actions have a changing variable set to its reference string, and it loops, using this same action again and again, it never updates the Reference on the new loop.

I hope that makes sense. I also tried with set FSM gameobject,int, and float.

If it doesn't make sense, then just take a look at the scene i attached before. The logic should make sure that the FSMs 0,1,2,3... have a string set to their own name, but only 0's changes. Take a look and see if the logic is right. Because i can't figure it out...
« Last Edit: July 01, 2014, 10:20:51 PM by bkups2003 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Fsm * Bug
« Reply #3 on: July 02, 2014, 06:04:35 AM »
Hi,

 Can you send a package with your scene, and I'll test.

 Bye,

 Jean

bkups2003

  • Playmaker Newbie
  • *
  • Posts: 49
Re: Set Fsm * Bug
« Reply #4 on: July 14, 2014, 11:52:46 PM »
Sorry for the late reply. I'm outside my city and won't be back until next month. I'm away from my computer too. But in the first post I did attach a simple scene that shows the problem. Could u take a look at it please?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Fsm * Bug
« Reply #5 on: July 21, 2014, 06:41:45 AM »
Hi,

 ok, I found the bug, Indeed, VERY good catch. I have forwarded to Alex for a fix.

 The issue is that out of optimization it would store the game object that was used and if you come back to the action ( like in your loop), then it avoids the checks, when it should not.

You can find the corrected actions here ( while they are pushed to the official version for the next release).

http://hutonggames.com/playmakerforum/index.php?topic=7909.0

typically, send an event passing the string as event data, this way you'll be able to progress in your feature implementation.

Bye,

 Jean
« Last Edit: July 21, 2014, 07:12:56 AM by jeanfabre »