playMaker

Author Topic: How to wait for a 'Send Event' action to complete  (Read 583 times)

GMPlay

  • Playmaker Newbie
  • *
  • Posts: 28
How to wait for a 'Send Event' action to complete
« on: September 14, 2022, 02:00:06 AM »
Hi,

For a 3d point and click adventure project:

I have an fsm (called player movement) setup for movement from one hotspot to another.

To move forward from player current hotspot,
a target is selected via mouse left click.

Similarly  to move to previous hotspot,
we press mouse right click to read 'previous hotspot' variable,
and then set that as a target.

Once a target is set,
I send that info along with an event (called TweenPlayer) on another fsm (called game manager).

The thing is,
the fsm player movement needs to do more stuff and must continue with a few more actions and then finally return to wait for player input again.

Meaning, the exact state where I send event (TweenPlayer) is (say) sixth state in the player movement fsm. But I have more (seventh, eighth) states ahead.

I need for the TweenPlayer operations in game manager to be finished,
and then only proceed to seventh state.

The Tween operation in game manager is set to 1 sec by default.

Right now the problem is that the right-click and left click can interrupt each other.

Meaning, if the player is moving forward and if we press right-click in less than a sec,
the moving forward gets interrupted midway and starts moving backwards.

I need the tween operation that is in progress  to be finished first , then it should be ready to accept new input, such that the ongoing operation doesn't get interrupted.

A temporary work-around I figured was to attach a Wait action of 1 sec on the sixth state right after send event action. 1 sec works because the tween itself is set to 1 sec. But,

Is there a more robust solution something like 'wait until event finished'   ??? 




« Last Edit: September 14, 2022, 02:12:12 AM by GMPlay »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to wait for a 'Send Event' action to complete
« Reply #1 on: September 14, 2022, 12:08:32 PM »
Hi.
Add a bool variable (cal it "is Running" for example) on the target object/fsm and before you send the event, use "Set Fsm Bool" and set running to true.


then use "Fsm Bool Test" (Ecosystem) and set every frame enabled.

on the target fsm use Set bool value and set is Running to false when your done with the things it needs to do.

GMPlay

  • Playmaker Newbie
  • *
  • Posts: 28
Re: How to wait for a 'Send Event' action to complete
« Reply #2 on: September 17, 2022, 06:27:32 AM »
Neat little trick!
Now why didn't I thought of this?

Thanks as usual  :)