0
\$\begingroup\$

Here is what I want to do:

  • when player jumps I would like to play an animation of jumping once

  • on playing it I would like to stop at the penultimate animation frame till the player falls to the ground

  • on falling to the ground I would like to play the last frame of the animation

Here is a screenshot which I hope will make my objective clearer:

enter image description here

Here is an idea I have right now:

  1. I will add an event to occur exactly between penultimate and last animation frames, this even will stop animation.

  2. When grounding I will add an event which will continue my animation to play till the end.

  3. At the end I will use a flag to say all other animations that they are free to play.

Here is stuff which I think is a flaw:

  • using of flags will make any code messier in general

  • there will be problems if a user jumps once and try to run, jump again or do something that needs an animation right away after grounding because the last frame will be playing at that time

  • I do not know how to stop animation, since according to this stopping an animation also Rewinds it to the Start, while I do not want to rewind it to start, but stop before the last animation frame.

\$\endgroup\$
2
\$\begingroup\$

Jump Animation in 2D Games

There are three main state in any Jump state which can be understood with the help of this image

.enter image description here

so for smooth jump animation-

First thing we need to set the First and Last frame similar so that it will be look repeatable.

Then we have a great conversation that

How many number of frame we need to apply for particular Animation. Its actully depend on your Game. If you are making a Mario style game you need less number of frame and if you are wanna make Limbo kind of game you need more animation sprite.

So for

Mario kind of game I prefer simple sprite sheet animation which has all the three type of stages animation.

and if you are intrested in making

Limbo kind of character animation you need to use Spine Tool which is best for your 2D Character Skeletal animation either character animation VFX animation. You can check it from this link also http://esotericsoftware.com/

Now what kind of animation you need to create is depend on your game . Like your character can do Double jump* or Wall Jump or either Single jump so you need to aware about all of the things first. so for

Single Jump: We can use single animation state in which you can use all the three animation sprite (e.g Jumping, Falling, Landing).

and for

Double Jump and Wall Jump You need to create a blend tree.(e.g jumping state, falling state, landing state)

I would like to show you my 2D Character Animation Controller and Blend tree.

enter image description here

Animator controller used to handle different conditions to handle or to switch between different state animation.

and

Blend tree is used to controller different state of a single animation state .Like Jumping( Jump, Fall, Landing).

\$\endgroup\$
  • \$\begingroup\$ I have two questions. They may be a little bit off topic, but I think you have an answers to them. Let us go in chat if you do not mind. \$\endgroup\$ – Yaroslav Jun 21 '17 at 19:35
2
\$\begingroup\$

It would be smarter to create a separate animation for the landing frame, and make sure your current animation is set to not loop when you click on it in the inspector. Use an animation controller to switch to the landing animation when you hit the ground.

\$\endgroup\$
  • \$\begingroup\$ Your solution is not an appropriate one. When I land if nothing is pressed I start playing idle animation. And that playing prevent me from playing landing animation, so I have to use a flag even if try to solve the issue in the way proposed by you. \$\endgroup\$ – Yaroslav Jun 21 '17 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.