Platformer: Player Animation Part 3 (continued)

Intro

In this article I go over the fixes for the issues from the previous player jumping and idle transitions.

Jumping to Idle Animator

We want the transition from jumping to idle to be instantaneous, so we want to change the Jumping parameter from a Trigger to a Bool. A Trigger parameters are good for animations that have multiple animation transitions it needs to make often. Trigger parameters are great for animations that have time to play like death animation, power up animation, etc. With Jumping now a Bool, we will set the condition for the transition from Jump to Idle to be Jumping = false.

When we jump and go to Idle, the transition is stuck. This is due to the Jump to Idle still has Exit Time true, meaning it needs to finish the jump animation before moving to Idle. By setting the Exit Time false, this will fix this issue.

Running to Jump Animator

We will use our new Jumping bool to make the transition condition from running to jumping. The Jumping bool will need to be true to make the transition play.

Jump to Running Animator

For the transition from jumping back to running, we will use the Jumping Bool parameter and the Speed Float parameter. If the conditions that need to be met for the transition to happen are Jumping is false and the Speed is greater than 0.1.

The Code

We are going to create a bool to keep track of when the player is jumping. We set it to false to begin.

When the spacebar is pressed, we set the jumping bool true, and set the Jumping animation bool to the jumping bool, which is true. This will play the jumping animation.

When we jump the character controller is no longer grounded or true, so nothing in the controller.isGrounded will run. When the player lands, or jumping bool is true and we will want to set it to false, as well as, the jumping animation bool to the jumping bool, which is now false.

Conclusion

This cleans up the animation transitions and makes the player movement more realistic. In the next part of the player animation, we will flip the player when move left and right.

--

--

--

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

Recommended from Medium

What Does the Great Resignation Have to Do With Kubernetes?

New announcement 14/03/22

Remote connect AWS windows EC2 without exposing public IP with Omniedge

How to deploy custom VMs in Azure?

Growing Object Oriented Software Guided by Tests — Chapter 3

Microsoft Graph API for taxonomy (beta) + SPFx

TWiGCP — “Anthos on other clouds, new Spanner features, and 100 Kubernetes episodes”

Manipulating Data With MongoDB

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

Giving our Enemies an Adjustable Chance for a Shield

2D Mobile Game: Player Movement

Add a custom template to Unity for new projects

Creating A Modular Powerup System in Unity