playMaker

Author Topic: Interrupt Sequence[SOLVED]  (Read 668 times)

zerodragonheart

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Interrupt Sequence[SOLVED]
« on: October 05, 2019, 02:38:43 PM »
Hi! I'm totally new at this. I've been reading a lot about my issue but i Couldn't find any answer.

Thing is i have this state machine https://i.imgur.com/VAY0PGW.png
and In the patrol i've made a sequence (as you can see in the image)
it follows those instructions very well, but i want that if the collider attached to the object touches the player, Interrupts that sequence and jump to another.
Is that possible?
note that if I delete the "action sequence" it will do everything at the same time and will screw my scripted patrol. 
« Last Edit: October 08, 2019, 06:07:25 PM by djaydino »

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 634
    • View Profile
Re: Interrupt Sequence
« Reply #1 on: October 07, 2019, 09:55:47 AM »
You could always decompose your state in a few more and add a new one dedicated to verify the collision, checking a boolean for example on another FSM.
You could also try a dirty solution by having a FSM on the player sending an event when a collision is detected and use that event as a Global entry somewhere in your current FSM.

zerodragonheart

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Re: Interrupt Sequence
« Reply #2 on: October 07, 2019, 10:01:00 AM »
Can I for example create 2 branches, one is constantly patrolling in loop and the other interrupts that loop if certain event happens? like a global activator?
can you give me an example?
tyvm!

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 634
    • View Profile
Re: Interrupt Sequence
« Reply #3 on: October 07, 2019, 01:10:22 PM »
Branches? Inside the same FSM?
You cannot do that.
Contrary to other visual scripting tools, there is basically one single flow and one single path followed by this flow, inside your FSM.

If you want two behaviors/scripts to run side by side (in parallel), you must use two FSMs, possibly on the same Game Object if it makes sense, and come up with a way for both of them to communicate; preferably with one FSM being more like the main one and the other being the satellite FSM, checking for changes in floats, bools, etc., or listening to events on its own and, if it gets triggered in a given way, then do something like, for example, forward an event it received to the main FSM, or send another one that's unique to both main and secondary FSMs, all of which will allow you to reroute the flow on a different path in the main FSM.

You can also use the Go To State action, it works inside a FSM is also trans-FSM and can help you avoid creating another event if you're sick of using so many events. :D

Also, this is where the actions that allow you to edit or keep an eye on FsmVars in other FSMs become useful. Some are found under Logic, others under the State Machine category (the reason why is more of a mystery).
You can also use the action that checks if a FSM's flow is a given state: Get FSM State.

Thore

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: Interrupt Sequence
« Reply #4 on: October 07, 2019, 02:53:15 PM »
Can I for example create 2 branches, one is constantly patrolling in loop and the other interrupts that loop if certain event happens? like a global activator?
can you give me an example?
tyvm!

If you have an event coming in, you can easily use that to interrupt the loop, by going to a state outside of that loop. A second FSM can check the collision and set a bool, for instance (using e.g. Set FSM Bool).

You can also incorporate the collision check into the loop. You can put a collision check state as part of the loop (at one or several places), and if nothing collides, it simply runs in a loop. But if collision is registered, it would leave the loop.

It’s a judgment call whether it makes sense to split the mechanic up into several FSMs.

zerodragonheart

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Re: Interrupt Sequence
« Reply #5 on: October 07, 2019, 09:57:06 PM »
Thank you very much guys! I'll use 2 FSMs and call the events when needed. I think it's the best solution. Tyvm!