playMaker

Author Topic: Bool Test action can't trigger event[SOLVED]  (Read 2287 times)

Louis.Law

  • Playmaker Newbie
  • *
  • Posts: 8
Bool Test action can't trigger event[SOLVED]
« on: October 22, 2019, 01:31:09 AM »
I'd like to run 'Bool Test' after 'Get Mouse Button', but 'Get Mouse Button' action is running and can't stop, Bool Test action can't trigger 'is true' event.

How can I fix this problem, thanks~
« Last Edit: October 29, 2019, 03:29:35 AM by jeanfabre »

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Bool Test action can't trigger event
« Reply #1 on: October 22, 2019, 02:38:50 AM »
You didn't select 'Every Frame' for the Bool Test.

It's running a single time on start up (and so returning False), then that's it. Every Frame will make it keep watching any waiting for that mouse click actuated bool.
« Last Edit: October 22, 2019, 02:40:45 AM by daniellogin »

Louis.Law

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Bool Test action can't trigger event
« Reply #2 on: October 22, 2019, 03:06:23 AM »
When I select 'Every Frame', it works, and I get error info:
Loop count exceeded maximum: 1000 Default is 1000. Override in Fsm Inspector.

I'd like to put the cube to mouse pos on every frame, what's wrong in my FSM settings?

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Bool Test action can't trigger event
« Reply #3 on: October 22, 2019, 04:03:03 AM »
When I select 'Every Frame', it works, and I get error info:
Loop count exceeded maximum: 1000 Default is 1000. Override in Fsm Inspector.

I'd like to put the cube to mouse pos on every frame, what's wrong in my FSM settings?

OK I'll start with the error itself;

You can't loop between states too many times per tick... or what ever it's measured in. So if state A goes to B, and the action in state B immediately returns to A (forming a loop), this is bad and has to be avoided. There are a number of ways to do so, and the right one will depend on the circumstances and things you need to achieve.

If you need it to actual constantly cycle between two states for some reason, do this by putting a Next Frame Event between them. So instead of going A to B to A, instead go A to B to C (which is the Next Frame Event) and then back to A. Or what ever variant, just slip the Next Frame Event somewhere in between the loop. This means it will wait 1 frame before continuing, thus avoiding the too many loops issue.

In regard to your overall problem; I don't think I can help unless I know what you are trying to do is, or what happens in the state that the Move transition goes to. Why does it immediately return back again? For example; is the mouse meant to always move, even after it's clicked? Or is the idea that the click will halt mouse movement?

The first problem I can see with many answers to this, is that a mouse click (even when meant to be a single click) can drag out over a period of time. Especially so if the user accidentally holds too long. Maybe you need to switch this so it uses Get Mouse Button Down, that way the next action can do a Get Mouse Button Up before trying to see if the user clicked again. Otherwise even a single click will register as many if the FSM keeps cycling back to check for a regular mouse button a dozens of times per second.

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Bool Test action can't trigger event
« Reply #4 on: October 22, 2019, 04:05:17 AM »
Oh I just saw your other screenshot.

So yeah, read the above for more understanding, but what I would is;

Add a Mouse Button Up to Move 2 (at the BOTTOM, since it performs actions in top to bottom order), then add another new state it transitions to with a Next Frame Event, which then transitions back to the Input 2 state. That will fix the loop issue and avoid it registering multiple clicks for a single click.

I think you will also need to flip that bool back at some stage or change the input to Get Mouse Button Down to transition, otherwise when it gets back to the Input action it will already remember the Bool as True. Come to think of it, that's where your bad loop came from.
« Last Edit: October 22, 2019, 04:27:35 AM by daniellogin »

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 773
Re: Bool Test action can't trigger event
« Reply #5 on: October 22, 2019, 06:33:55 AM »
You can't loop between states too many times per tick... or what ever it's measured in.

Frames. :)

There's an option in the FSM tab to change that limit but it shouldn't be done, for obvious reasons.

Louis.Law

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Bool Test action can't trigger event
« Reply #6 on: October 22, 2019, 07:52:49 AM »
When I add a 'Next Frame Event', send event 'FINISHED', the loop issue is fixed.

Thanks, daniellogin!