playMaker

Author Topic: Loop count exceeded with fire button handling [SOLVED]  (Read 2253 times)

BryanPope

  • Playmaker Newbie
  • *
  • Posts: 3
Loop count exceeded with fire button handling [SOLVED]
« on: July 04, 2013, 03:23:09 PM »
I have the four way direction working with boundaries in each direction, but I am having a problem with the fire button input, in that I am getting the "loop count exceeded" error.

In the PlayerController part I get the state of the Fire1.  If it is pressed, I go to the FirePressedEvent.
In here I only want to fire a shot every nextFire seconds, but fire every nextFire seconds if the user holds down the fire button.  The connection between this and PlayerController is where I am getting the "loop count exceeded" error.

What am I doing wrong?  Is there a better way to handle this? 

Cheers,

Bryan
« Last Edit: July 05, 2013, 08:24:35 PM by BryanPope »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Loop count exceeded with fire button handling
« Reply #1 on: July 05, 2013, 12:04:27 AM »
Following the events it looks like you've created an infinite loop when pressing the fire button:
PlayerController > FirePressedEvent > FireShot > PlayerController > FirePressedEvent...

To break this loop, add a Next Frame Event to FireShot. This will fire the shot and then return to PlayerController in the next frame.

If you need to move while holding the fire button it would be best to make it a separate FSM (E.g., FireController).

Generally parallel behaviors should each have their own FSM. A state machine can have only one active state, so if you start describing states with an "and" (E.g., Moving and Firing) then you should probably split up the FSMs (a MovingFSM and a FiringFSM). You can do it in one FSM, but things get complicated quickly and it becomes harder to add new states. It's better to use multiple simple FSMs.

Hope this makes sense!  :o

BryanPope

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Loop count exceeded with fire button handling
« Reply #2 on: July 05, 2013, 08:23:55 PM »
I think it made sense, cause I think I finally got it! Thanks!  Here is what I have now that *does not* cause the infinite loop aka "loop count exceeded" error:

Hopefully that is what you were talking about?

I also found that you *do not* want a FINISHED event at the end of FirePressedEvent via the Float Compare "less than".  Doing this will get you the "loop count exceeded" error.

Thanks again!,

Bryan