playMaker

Author Topic: Break from current active state  (Read 1981 times)

Grendal

  • Playmaker Newbie
  • *
  • Posts: 31
Break from current active state
« on: August 27, 2015, 05:47:57 PM »
Long time owner, short time user question so I may be missing something simple.

I have a mob AI FSM that simply plays an idle then at a random interval jumps to a animation picking state to play simple idle adds like scratch, look around etc. then when animation done it jumps to a third state that sets a random rotation value and then jumps to either a right or left rotate state. Lastly when itween rotation done it flows back into the main idle state.

I intend to have sensory FSM triggers send events back to this MainBrain FSM when player is spotted via raycast, or enters a proximity trigger, etc.

My question/concern: Is there a way to break out of the active idle states system and jump to movement/targetting states when these event transitions arrive or will I need to store them in variables and check those upon arriving back at idle to start reactions to the external input? I could do this with minimal delay since the idle system runs fairly quick but it would only work well for dumb mobs...

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Break from current active state
« Reply #1 on: August 27, 2015, 10:44:13 PM »
If I understand correctly, what you are looking for are global events. You make an event global on your brain that when player is seen it automatically jumps to that new event no matter what state its in.

You can also control if to accept the event or not by setting it as a regular transition so for example... In another fsm we have a raycast looking for player. Boom. Found player, raycast sends event to go to a new state. In that state you use send event by name. You can set that action to send to any game object you want including self. Now in the brain with the animation states you created a new event called react and made it a global by clicking the checkbox next to it. Now you right click the state you want it to go to and set a global transition. You set the name "react" in your raycast fsm and now it will fire the global event named react.

If you want it to only happen on your idle state, then you right click idle and set up a normal transition using "react" event to the state you want the reaction to be and now when the raycast sends event by name, it will only send it to the reaction state if the brain is currently in idle. That should do the trick.

Now if that is not what you were looking for then I hope this wall of text proves useful to someone.
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

Grendal

  • Playmaker Newbie
  • *
  • Posts: 31
Re: Break from current active state
« Reply #2 on: August 27, 2015, 11:11:15 PM »
That is basically how i was planning to set it up; external fsms that fired trigger global events back to main control fsm (brain) where further states would decide the appropriate response. My main concern was whether the global event upon arriving in the brain fsm would take over the fsm and immediately exit the idle actions animations state chain. Do global event sent from other fsms take precedent upon arriving over currently activated states in the receiving fsm?

I am at work and unable to test this.. I will set up a test when I get home tomorrow if still not sure.

If they don't... is there a "Stop all and do this..."

I am really over thinking this.. I could just send bools from each external fsm and compare them during each transition of my idle state chain and jump to react state with 1/3 less time than waiting till done.. or rewrite my "chain" into one state with a repeat state... coding (visual or script) is so much fun... 100 ways to do something.

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Break from current active state
« Reply #3 on: August 28, 2015, 10:00:32 AM »
Yes it does take precedent over any state. Like you said what you could do is set up a bool in your animation state to true, and get that bool from the other fsm and check if bool true then dont fire global event until bool is false.

Or the other method that I stated which was to set the event as a regular transition event on the next state so the idle won't be affected.

You can also set up delays and even kill those delays. Like you said there are tons of ways to do anything. Finding the most efficient way that works for you is the fun part :D
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez