playMaker

Author Topic: Animation problems  (Read 5650 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Animation problems
« on: July 29, 2013, 09:36:01 AM »
Hi!
I have a little problem with the animation. It's working almost perfectly, but
when I click the right arrow to walk to the right and then I click the left arrow to walk to the left, before I release the Right arrow. The character goes straight to the idle animation. I know why it's happened, but I can't figure it out by myself.

Here is a screenshot of the animation FSM



Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Animation problems
« Reply #1 on: July 29, 2013, 09:53:01 AM »
Hi,

 I think you should sperate this into two fsm. one that deals with the user input and one that deals with the animation triggering.

fo, FSM Input would always check for user input and fire global events based on this, like "WALK LEFT", "WALK RIGHT", "WALK", "STOP", etc

and Fsm Anim would implement these events as global transition and animate accordingly, this will prevent messing with cehcking user input in different states.

 also, your problem might also be due to the way you check for input, what actions are you using to check user input?

bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Animation problems
« Reply #2 on: July 29, 2013, 05:19:49 PM »
Hi!
Thanks for the answer!

I use two FSM. One for the input and one for the animation.

In the FSM with the inputs, I have this actions:
-Get Key Down
-Smooth Look At Direction
-Controller Simple Move
-Get Axis Vector

But I think the problem is on the FSM for the animation

There I use these actions
On "State - Standing"
-Play Animation
-Get Key Down - Left Arrow
-Get Key Down - Right Arrow

Walking right State
-Play Animation
-Set Animation Speed
-Get Key Up

Walking Left State
-Play Animation
-Set Animation Speed
-Get Key Up

I don't know if this is the best way to do it. I just followed a tutorial for this. :)
Here is a screenshot of the input FSM. Is very simple

Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Animation problems
« Reply #3 on: July 30, 2013, 08:04:20 AM »
Hi,

 why do you have keydown actions on your animation states? that's where the problem could be. your animation state must not check for anything, it should only implement events that your input fsm fires.

bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Animation problems
« Reply #4 on: July 30, 2013, 01:03:40 PM »
Ok! So how can I do it different?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Animation problems
« Reply #5 on: July 31, 2013, 02:49:24 AM »
Hi,

 Like I explained, completly separate the input logic from the animation logic. Only check for key up in your input fsm, and fire a global event to your animation fsm. Then you can properly design your input management, and test your animation system separatly. This will be easier in the end.

Do you have problems designin the input fsm or the animation fsm?

bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Animation problems
« Reply #6 on: July 31, 2013, 06:59:17 AM »
Hi!

The input FSM is fine. It's the animation FSM I have problems with.
So in the animation FSM, how can I call the input FSM? Because the animation FSM need to know when I push the left and right button or jump button, etc. right?

If you have time, I would be very grateful if you could give me an example.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: Animation problems
« Reply #7 on: July 31, 2013, 08:45:48 AM »
Hi! I hope i can offer a way to solve this problem

In your animation FSM, you have an idle start-state with transitions into 3 or 4 states (walk foward animation, walk left animation, walk right animation and walk backward animation) so 5 states in total including start state. You make a global event for each of them, and add them as global transition (example: move forward state has the "play animation" action that makes it play the move forward animation. On this state you right-click and "add global transition" and attach your "move forward" transition to that state. Same with all the other states with their corresponding transitions.

The start state will be the "idle" state that plays the idle animation and nothing else.

Now go to your input FSM. In the input state for forward, you add a new action called "send event" and change target to "game object FSM". Then let it stay at "use owner" and enter the name of your animation FSM and in the "send event" field, you chose "forward" (or your corresponding name for your global forward animation transition)

Repeat for all the other states.

This ensures that when you use your move foward input, it sends an event to your animation FSM and plays the forward animation automatically, and this should work for all your animations.

I hope I explained this well enough

Good luck!

-Koz
« Last Edit: July 31, 2013, 08:48:29 AM by KozTheBoss »
Remember, you don't fail unless you give up trying to succeed!

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Animation problems
« Reply #8 on: July 31, 2013, 11:07:19 AM »
Hi, KozTheBoss!

I tried your example. I upload a screenshot of the Input FSM and the Animation FSM. But I need to connect this states to each other. Does I have done it correctly so far?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Animation problems
« Reply #9 on: July 31, 2013, 11:09:02 AM »
Just to say that I only have left and right movement
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: Animation problems
« Reply #10 on: August 01, 2013, 07:35:02 PM »
Yes, the states are set up correctly. However on your input setup, you need to be able to go back to idle state when you let go of the key, right? Use a "get key up" action and use that to move back to idle state in both left and right. with your current input setup, you can not switch from walking LEFT to walking RIGHT either, before you let go of the LEFT key. I suggest connecting the LEFT and RIGHT states aswell, and also listening for key input to change direction there.

What i mean is in your left state you will listen for button RIGHT and if buttong RIGHT is pressed you will go to the RIGHT state and vice versa.

This makes movement feel better as you can switch between the 2 states without having to go back to idle state first.


Now for the animations - What you have done looks correct. In the left and right states in the INPUT FSM, as i stated in my post above, you should use the SEND EVENT action to send the correct transitions for the left and right animation states in the animations FSM. :)

Here, You should also make a global transition for the idle state so the character can play idle animation when the INPUT FSM is in the idle state aswell using the same method :) Hope this is understandable - If not, let me know and i can make an example for you!

-Koz
« Last Edit: August 01, 2013, 07:39:20 PM by KozTheBoss »
Remember, you don't fail unless you give up trying to succeed!

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Animation problems
« Reply #11 on: August 02, 2013, 12:02:45 AM »
Another possible option... taking a page from Jean's suggestion if instead of using the up/down actions, would it be something to consider to just use the "get key/button" actions, stow the status into a boolean value that you can have the other FSM read?

So, FSM one, only handles monitoring the state of the pertinent buttons... you can add in the "Set fsm bool" actions to feed this to the animation controllers.

State two, you could have the transitions controlled by bool tests...

So, "Walk right" state can watch for either the "walk left" button being true or the "Walk right" button value being false... for the walk left, you could transition right into the walk left and vice versa... and if none of the booleans are true they revert to the idle state? and this would all be where the animation is controlled. personally, i'd have the movement systems be handled in another FSM... mainly to keep things cleaner.

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Animation problems
« Reply #12 on: August 03, 2013, 04:16:25 PM »
Hi!
I think I'm very close now to get this working. The animation is working when I'm walking in all directions. But it's something wrong when I change direction to fast. Then it's going straight to the idle state. Again! Here is the screenshots. Maybe you can make an example if you have time? :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no