playMaker

Author Topic: State not reached  (Read 2223 times)

cdutoit

  • Playmaker Newbie
  • *
  • Posts: 30
State not reached
« on: February 04, 2015, 06:47:31 AM »
Hello - I'm fundamentally not standing one aspect of FSM's. I've built a few and they work great (love Playmaker) but have come across a situation I'd like some help understanding better:

I have the following FSM:



It works exactly as you might expect - it is attached to an object. When I click mouse down on the object,"State1" briefly goes green, then I drag the mouse, "State 3" goes green and finally I release the mouse and "State 4" goes green. All the mouse events are properly caught.

Now for the part I don't understand. In the diagram above, I never get to State5 of the mouse drag.

State3 is getting the mouse positions and spawning an object (getMouseX, getMouseY, ScreenToWorldPoint, Create gameobject). Then I wanted to move to the next state to do some more actions (logic checks etc) but it never goes out of State 3 (ie. The Finished event is never called). When I release the mouse button, State 4 is correctly invoked.

Can you please help me understand how or why State 5 is never reached? And what is the workaround - for example, in State 5 I want to check if the distance from the current mouse pos is > distance from last mouse pos, but since I can't do anything past State3, I can't branch out.

Thanks for any tips!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: State not reached
« Reply #1 on: February 04, 2015, 07:25:08 AM »
If there is an action in the state that is run in the OnUpdate loop or is using Every Frame then the FINISHED system transition will never fire because the action stack is not "finished".

Thats probably the case here.. Since state 3 is basically an active state that should not be left you may want to look into putting whatever is in State 5, into State 3. There's nothing wrong with having a long stack of actions that operate top to bottom every frame. For instance you can do several math actions on a variable every frame and at the end of the math stack use that variable somewhere every frame and it will work fine.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

cdutoit

  • Playmaker Newbie
  • *
  • Posts: 30
Re: State not reached
« Reply #2 on: February 04, 2015, 09:02:50 AM »
Thanks, Lane. I *think* I understood...if still a little confused :)

The problem however is that I cannot stack all my operations in "State 3" since I need to do if/then/else branching logic. So I need to be able to progress to another state ("State 5") to continue the decision tree.

Any input is appreciated!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: State not reached
« Reply #3 on: February 04, 2015, 09:06:43 AM »
Then those conditions need to fire an event specifically. You can use the Conditional Expression action if you need to but I would first check if there are some standard actions that would support your case. For instance Float Compare, or Bool All True.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D