Platformer: Player Animation V — Idle Jump

Intro

In this article, I cover how to add an idle jump animation to the growing player animations.

Setup

For the animation we are going to Bake Into Pose all of the Root Transform because we are controlling the jumping height through the script and we do not want the animation to be controlling the animation.

We addd the Idle Jump animation to the Animator window. We want to be able to only transition to this Idle Jump if we are in the Idle animation. We will use a trigger parameter called “IdleJump” to go from Idle to Idle Jump.

The transition settings for Idle to Idle jump will be no exit time for the Idle animation, so we can go straight into the jump and the transition duration is 0. This, again, will transition instantly to the Idle Jump animation. The transition offset is .2. This starts the Idle Jump animation a little late to cut out some of the idle standing before the jumping animation starts.

The transition setting from Idle Jump to Idle is we will have Exit Time because we want to finish the entire Idle Jump animation before going back to Idle.The Transition is .25 so there is some blending between the Idle Jump to Idle making it look a bit smoother.

Code

Looking into the Player script, we just have to adjust the jump segment of the code. Jumping takes place when the space bar is pressed and the direction on the Player’s Y is increased by the Jump Height. After this, we will use the horizontal input to check if the Player is moving. If the horizontal input is = 0, then neither of the left/right arrow keys are being pressed so we are not moving. This is where we will trigger the “IdleJump” parameter. Else, will handle if the Player is moving and will handle the Running Jump functions for that animation that was previously in the code.

Conclusion

There were some other Idle Jump animations that were more visually appearing that I would like to revisit. The only reason I didn’t use them was figuring a way to pause the jumping movement for the Player a bit to sync up with the animation. This is not a bad start and as I learn more about the Animator I will revisit this animation. Until then…Cheers!

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Practical Azure: Secure a .NET Core Web API using Azure AD B2C.

How we use Markdown in Laravel Mailables

High Availability Structure Using AWS CLI

REST API & Koa JS

Setup Xdebug in Laravel 8 like a boss

Everything you need to know about indexing and range() in python.

How to solve problems as a software developer

Simple Cache Busting/File Revving with MD5 and Server Rewrites

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ryan McCoach

Ryan McCoach

More from Medium

2D Mobile Game: Player Jump Optimized!

Reflection Probes in Unity

Moving Platforms in Unity

Benefits of Prototyping Without Assets