playMaker

Author Topic: Enemy FSM keeps getting stuck in Idle state after detecting player  (Read 760 times)

fnfunkin

  • Playmaker Newbie
  • *
  • Posts: 1
    • fnf
Hi everyone, I'm pretty new to using PlayMaker with Unity and I've run into a problem with my enemy AI FSM that I can't seem to solve. For context, PlayMaker uses a visual state machine system with states, actions, and transitions to control behaviors in Unity, which is why I’m trying to handle my enemy logic entirely through FSMs instead of C# scripts.

Right now my enemy has three states: Idle → Chase → Attack. In the Idle state I'm using Get Distance to check the distance between the enemy and the player, then I send an event called PLAYER_NEAR when the player is within 10 units. The transition to the Chase state is set up correctly, and I can see the event firing in the debugger, but the FSM sometimes just stays in Idle and never transitions.

What’s confusing is that it works sometimes, but other times it doesn’t trigger at all even though the distance value clearly drops below 10. I’m wondering if I’m misusing the Every Frame option or if my event setup is wrong somewhere. Has anyone run into this before or knows the correct way to reliably trigger a state transition based on distance? Any help would be really appreciated!

GrumpyGameDev

  • Playmaker Newbie
  • *
  • Posts: 35
  • I make games
Re: Enemy FSM keeps getting stuck in Idle state after detecting player
« Reply #1 on: March 17, 2026, 12:30:41 AM »
after you get the distance between the two in one event wait one second then transition onto the next event comparing the player units. After that it should work correctly. You have to wait a frame with the now newly added distance number for it to be compared correctly and not just zero everytime with all the actions in one event. Hopefully that all makes sense