playMaker

Author Topic: State Update still getting called [SOLVED]  (Read 3263 times)

xtr33me

  • Playmaker Newbie
  • *
  • Posts: 9
State Update still getting called [SOLVED]
« on: November 15, 2011, 10:53:33 PM »
There is somethign I am missing here and just wondering if there are some rules I just havent learned yet.  I have an Idle state, infected state and dead state which I have attached c# scripts to. Right now for some reason when my block goes into the dead state, it is still calling the update on the infected state also.  The below lines get called when I pass into the dead state.  From what I was seeing in tutorials, it looked as if the "Finished" event had to get called so I did so.  Are there any other rules I am supposed to follow that I am not that could possibly cause my state to call both updates?  And yes, both the dead state update and my infected update are getting called for the same object.  TIA!!

When I proceed into the dead state I call:
myCube.fsm.Fsm.Event("CUBE DEAD");
myCube.fsm.Fsm.Event("FINISHED");

When I am in the playMaker log all looks fine and as it should, but when I put a breakpoint in the update of the infected state script, it steps in and it is the only object on the screen that has gone through the infected state as well as now being in the dead state.
« Last Edit: November 16, 2011, 04:15:51 PM by alexchouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: State Update still getting called
« Reply #1 on: November 16, 2011, 12:56:48 AM »
Hi,

 One thing to be aware off: if you have the same custom action or action attached to several state, putting a break point inside this action script will trigger from which ever state is currently active. It's kind of obvious but a real limitation when you want to debug the old fashion way.

I am not sure why you need to call the "FINISH" State. Doesn't seem a good practice. the "finish" event is something special in many ways, has it triggers automatically when all actions within a state have finished there jobs. It's of course valid, but maybe a rework of the flow is required at that point ( like have a specific event as transition that you call instead of the "finish"

If that's not the problem.

Could you make screenshots of the fsm and its state content ( all the actions), then I'll give us a better view at what you've set up.

Pm me if you feel this will be easier for me to look at this ( if possible of course).

bye,

 Jean

xtr33me

  • Playmaker Newbie
  • *
  • Posts: 9
Re: State Update still getting called
« Reply #2 on: November 16, 2011, 10:53:05 AM »
Thanks Jean!  I am at work right now and will post more info later when I am home.  Something I did notice this morning before I went to work was a checkbox that said something like "Remove script on exit".  I checked that on the states and it seems to have fixed the issue, but I don't fully understand this because it loked as if the fsm still worked even after I reset the state back to idle (which is exactly what I want).  It also seems that this prevented the multiple updates from getting called, but I dont understand how I am removing the script on exit yet the next time around the script is working.  I only instantiate these cubes on stateup and then I just reuse them, so I thought that if I removed the script that it would not work the way I wanted.  Again, I will look more into this later on tonght and post whether is worked or not and if I need mroe assistance I will surely provide more info.  I also removed the "Finish" event clals and everything still worked the same, but if I don't need it then I won't call it :)  from what I had seen in tuts it sounded as if I had to call it for the system to knwo the state was finished...thought it was werid but glad to see it wasn't nescesary.  Thanks again for the help!

Dan

xtr33me

  • Playmaker Newbie
  • *
  • Posts: 9
Re: State Update still getting called
« Reply #3 on: November 16, 2011, 12:25:51 PM »
So there it is. https://hutonggames.fogbugz.com/default.asp?W53

I made the assumption that when this object was created, the scripts were attached, but as the note says: "The script will be added to the game object when the state is entered" , I guess it is attached when the state is entered.  So therefore every time I was re-entering my state I was adding another script to the existing one.  By checking "Remove on Exit" it removes it and then the next time I enter the state, it is added again and only uses that state.  Now Im kinda curious as to why you wouldn't want this happening by default to begin with.  Don't understnad why you would want multiple scripts attached to the objects overall state.  Either way, after testing it seems to be working as I want.  Only the update of the current state is called and the others are not once exiting.  Thanks again Jean for your response!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: State Update still getting called [SOLVED]
« Reply #4 on: November 16, 2011, 07:54:21 PM »
no problem, Glad, you sorted it!