playMaker

Author Topic: get key vs. get key down - loop count exceeded problem - [SOLVED]  (Read 3376 times)

gbug

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Hi, I've finally started to use playmaker and it all went great so far and my prototype was coming along nicely. Until now that is. This problem is driving me rather crazy and so I thought I'd ask here instead of wasting more time trying to understand it on my own. Thanks for any help.

So in my project I have an input manager FSM that checks for keypresses every frame and stores the results in bools which I check in my movement manager FSM and act accordingly. All worked perfectly fine until I went to work on my latest state, at which it got stuck with the loop count problem. I tried a ton of things and it seems it boils down to what's in my screenshot.

I've made an as simple as possible version of my problem to show and to make sure nothing else was influencing it.



Why does it transition into the empty state just fine with get key down, but not with the bool test?
What makes it even more confusing to me is that in my actual project which is more complex, the loop problem vanishes or comes back depending on what I do in the state. Setting float values and having a wait works fine, but as soon as I have a float compare in it for example, it throws the loop count error again and I can't get rid of it any way as long as the float compare is in there. (which gives proper results for sure since I compare 1 to 1 and send events properly).

So I guess it has something to do with how the get key/get key down actions work, since it all resolves as soon as I use get key down to switch states instead of the bool test. Which is not really a solution to my problem as opposed to this old thread showing the same problem:

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

which really just got [solved] because the poster changed his logic, rather than anyone fixing or explaining the actual problem. I hope this time around anyone can shed some light on this? Thank you.

EDIT: After some more testing and thinking it sounds more logical that something in Bool Test is the cause and how that fires events compared to how Get Key Down does. Since it doesn't matter where the bool value comes from. Using Bool Test to enter the next state will give problems regardless if set directly or coming from get key.
« Last Edit: January 30, 2014, 10:55:38 PM by gbug »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14126
  • Official Playmaker Support
    • View Profile
Re: get key vs. get key down - loop count exceeded problem
« Reply #1 on: January 30, 2014, 03:46:15 AM »
Hi,

You can't have that kind of setup in PlayMaker. I think you are missing some concepts on how to create Fsm.


Why do you think you need this empty state?

bye,

 Jean

gbug

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: get key vs. get key down - loop count exceeded problem
« Reply #2 on: January 30, 2014, 05:05:05 PM »
Hi Jean,

I don't need this empty state at all. I just made the most simple setup to illustrate the problem so you don't have to look at a more complex FSM with lots of non relevant stuff going on. Since the 2nd state itself can't be the problem, I just left it empty in that example as to focus on the actual problem. Seems it ended up as a distraction instead. Sorry for that.

The actual problem was that when I switch to another state with get key down it works fine, but if I switch to the very same state with a bool test, it tells me loop count exceeded.

Since I posted the question my project changed quite a bit and the effect of the problem persisted, but changed forms. After your reply today I spent some more time trying to figure it out and was able to narrow it down to the fact that Bool Test has an OnEnter() component while Get Key Down does not.

So I made a duplicate of the Bool Test Action and took out the OnEnter() part and my FSM works fine now. No infinite loops.

That said, before setting this thread to [solved] I would still like to understand the root of the problem. Why is there an infinite loop warning when Bool Test sends an event in OnEnter() , but not in OnUpdate(). Thank you.

Here is my current projects FSM and then below a tidied up version with the non relevant states taken out and a bit of explanation.






gbug

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: get key vs. get key down - loop count exceeded problem - [SOLVED]
« Reply #3 on: January 30, 2014, 11:21:12 PM »
I just figured it out and of course it was my mistake and it made me feel stupid. Should have learned to use debug and stepping earlier. Sorry Jean. Loops really do happen so damn fast.

The problem was that a value I was checking against 0 in the next state starts out at 0 in the state I use the Bool Test in and since that sends the event to go to the next state in OnEnter(), the value never gets a chance to go beyond 0. However, when the Bool Test sends the event in OnUpdate() the other actions already changed the value to be not 0 anymore and things work out as intended.

That said, do the OnEnter() parts of actions not finish in the same top to bottom order of how states go through actions? I had the Bool Test on the very bottom and shouldn't have all the other actions before that (which change the value from 0) already have finished by then?

Thanks for your patience.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14126
  • Official Playmaker Support
    • View Profile
Re: get key vs. get key down - loop count exceeded problem - [SOLVED]
« Reply #4 on: January 31, 2014, 05:10:29 AM »
Hi,

 That may be due to you setup as is. I am not sure, your states are complex so I would think that the issue is also in the design as opposed to the action itself... ;)

bye,

 Jean

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
    • View Profile
Re: get key vs. get key down - loop count exceeded problem - [SOLVED]
« Reply #5 on: January 31, 2014, 10:03:58 PM »
Gbug, from my experience, it seems as though "every frame" actions (even if they don't have "every frame" ticked) will activate regardless of the actions before them, ignoring the usual top down order, like you said.

If this becomes an issue for me, I separate the state in two. First state is everything I need to change/calculate/whatever, and when that finishes, it passes to a new state which has just the "bool test" or "on trigger enter" states. You'll start learning when you need to split them, it will become second nature soon!

You and I are alike in that we have some crazy complicated FSMs. I secretly think we might be geniuses.  ::)

I often find that my FSMs are so complex, I'm usually able to find out the problem by taking a third or fourth look at my FSM. It usually takes a while for people on the forums here to even have an idea what might be the issue because, well, my FSMs are hard for even me to understand. Keep at it and let us know if you have any issues!

Just for fun, here's a picture of one of my FSMs:
« Last Edit: January 31, 2014, 10:09:38 PM by Breadman »

gbug

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: get key vs. get key down - loop count exceeded problem - [SOLVED]
« Reply #6 on: February 03, 2014, 03:38:56 PM »
@Breadman

Thank you a lot for your reply. It helps to see I'm not the only one doing complex FSMs that are not easy to follow right away.

I'll have to do some more testing to understand the OnEnter() OnUpdate() order of execution better, as it seems I just ran into another weird behaviour originating from that, but I'll be sure to try your tip about separating the states where possible.

Quote
You and I are alike in that we have some crazy complicated FSMs. I secretly think we might be geniuses.

I like your style ;)

What kind of project are you working on? Any links I could check out?

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
    • View Profile