playMaker

Author Topic: Axis Event.Which has precidence?[SOLVED]  (Read 1868 times)

wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
Axis Event.Which has precidence?[SOLVED]
« on: March 01, 2015, 11:47:05 PM »
On the action 'axis event', is there a precedence for the UDLR?

I am trying to get animation to work.  Each of the 8 directions has a different animation to play (and more).  So I was thinking it goes top down so left-right-up-down.  If one of those is met, it'd exit.  However, this does not seem to be the case.  What I would like to do is have different animations play for: Left, right, left-forward, left-back, right, right-forward, right-back, back, forward. 

I have a plane with engines on them.  The should rotate going left, right, forward or stop.  Also, slow or fast in those configurations.  I can almost do this, but it seems like when I do DOWN then LEFT or RIGHT, it doesn't play the proper animation.

BTW:  the animation is just 1 frame using legacy animation.  Nothing special.
« Last Edit: March 02, 2015, 01:47:27 PM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Axis Event.Which has precidence?
« Reply #1 on: March 02, 2015, 06:25:02 AM »
Hi,

 This is a typical problem that you will only be able to solve using a timer.

 same thing for double click, you can't expect to catch a double click without a timer, here you want to know before you fire any single key stroke, if yindeed ou have a combo ( Up-Left).

 So, the easiest way, if you are not too keen on complex dynamic fsms, you hard code your combo in your fsm logic.

 start with a axis event, you catch all of them, and each goes to a specific state, that then only listen to the potential combo, with a timer to exit that state, which would lead to trigger the initial event.

example:

state 1: listen to all events
 -- left key is fired - go to state "Left key"

state "Left key", only listen to up and down events, with a third action with a timer of 0.2 s, leading to a state firing the LEFT animation. if up or down key is hit before  the timer, you fire the left-up anim or the left-down anim.

 does that make sense?

for the braves, you can do all this dynamically, using ArrayMaker, with an arrayList per combo, and on each key stroke you check what array current index matches the key and move the current index to the next item and watch for this one, once the array has no more items, it means this combo was performed. I have done this for morse code :) so one could make a game where the player had to do various morse to progress, which meant not a real possibility to hardcode each morse code in an fsm.


 Bye,

 Jean

wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
Re: Axis Event.Which has precidence?
« Reply #2 on: March 02, 2015, 01:43:02 PM »
"state "Left key", only listen to up and down events, with a third action with a timer of 0.2 s, leading to a state firing the LEFT animation. if up or down key is hit before  the timer, you fire the left-up anim or the left-down anim."


I actually thought of that.  It just seemed like a workaround.  I did find a 8 way axis and this works.  The key was to set the animation to 'type 1' and to 'clamp forever'.  I have 2 fsms doing the horizontal and vertical at the same time (on 1 fsm you can't move diagonally) and then I have a fsm playing the animation.

BTW: if you are reading this and wonder what the 'nothing' state does, it is just a placeholder so there are not 9 lines over top of 9 other lines.  This way, only 1 line goes back to the axis wait.  just a little trick to keep things easier to read.
« Last Edit: March 02, 2015, 01:52:39 PM by wheretheidivides »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Axis Event.Which has precidence?
« Reply #3 on: March 02, 2015, 01:47:14 PM »
Hi,

 Very good!

 Bye,

 Jean