Page 1 of 1

Looking for animation logic

Posted: Sat Sep 28, 2019 5:16 am
by ilovelove2019
Hello everyone. I had a problem that had been around for a long time, ever since I started learning game programming until now. Every time I make projects about platform games, I meet them. The problem is how to manage animation for the movements of the character in the most reasonable way. I want animation to suit each type of character movement such as: jump, run, ... Every time I develop more features for the character, adding animation for me is very difficult. I have tried many but have encountered bugs every time. That is logic error.That made me depressed and had given up with many games.

More specific. My character has these animation: idle, run, jump, crouch, climb, hurt. I need your help. I meet a lot of logic error when manage them. I think I don't have a proper method yet. Can anyone help me please? Thank you so much!

If you need I will send my dump code in the comment.

Re: Looking for animation logic

Posted: Sat Sep 28, 2019 6:17 am
by ivan
I wrote a short tutorial on how to make animations:
https://2dengine.com/?p=animation
There are more sophisticated libraries out there,
but I think you can easily implement it yourself.

Re: Looking for animation logic

Posted: Sat Sep 28, 2019 8:10 am
by ilovelove2019
Oh. May be my bad english make you miss understand.

Re: Looking for animation logic

Posted: Sat Sep 28, 2019 8:58 am
by ilovelove2019
I use anim8 library to make animation. It's OK. The problem is logic. I don't know how to switch animation when player walk, jump, hurt,...

Re: Looking for animation logic

Posted: Sat Sep 28, 2019 11:52 am
by ivan
Oh, I see.
This is actually a very good question.
You could have different states for the player where each state has its own animation.
Just keep in mind that the player only be in one state at a time.

Re: Looking for animation logic

Posted: Sat Sep 28, 2019 12:08 pm
by ilovelove2019
It mean I need to create a variable named state to storage state of my player?

Re: Looking for animation logic

Posted: Sun Sep 29, 2019 8:20 am
by ilovelove2019
Ok. I use that method and to now everything works well. Thank you.

Re: Looking for animation logic

Posted: Sun Sep 29, 2019 12:11 pm
by ivan
Take a look at my tutorial:
https://2dengine.com/?p=fsm
I have modified it specifically to answer your question.

Re: Looking for animation logic

Posted: Sun Sep 29, 2019 2:19 pm
by ilovelove2019
Ah yes! Good solution. Good tutorial. It help me a lot! Thank you!

Re: Looking for animation logic

Posted: Sun Sep 29, 2019 2:32 pm
by ilovelove2019
I have visited your site. And I see your work so amazing! I see you have some project public on Steam. Good work. Keep doing.