Using the Unity Animation System

Let’s implement the animations, but first I have to implement a model for our player, we can not continue with the capsule that currently acts as a placeholder.

The time has come to animate it, luckily our package gives us not only the model but also a couple of animations to use. Mainly we will use two animations its “Idle” which will be active when it is really still, and the walking one when we move between two points.

Select the 3d model and add the Animator component. We will be asked for a “Controller”. Then in our animations folder let’s create one for our character.

Double-clicking on it will open the animator tab.
We drag the animations we want to use into this tab in our case Idle and Walk.

The idle animation will be linked directly to the entry block, instead of for the Walk animation, we need to build a transaction between the two animations.
To do this, right-click on the mouse and choose to Create a Transition and link to the next block. You have to do the same thing in reverse between Walk and Idle to return to the starting state.

Once we have inserted the two transitions we must define how the transaction between the two states takes place. To do this in the animation tab click on Parameters and create a bool variable, in this case, the bool is perfect because we have only two states.

Finally, we pass to the code, we have to modify the parameter just created when the movement takes place and reset it to the initial value when the distance between the player and the destination is less than 1.

PlayerMovement is called in Update method

--

--

--

project manager by day, unity developer by night

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

Recommended from Medium

Twitter API V2 Programming with Python and Tweepy

How to Teach Yourself Coding

Install Istio:Part 2: Helm and Istio

AWS Athena — controlling access to your datasets

Restarting HTTPD Service in Ansible is not idempotence in nature

Building a declarative animation framework in Swift — Part 1

How to add reCAPTCHA to Bootstrap contact form

KOF ALLSTAR × 街霸V實施合作活動!

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
Andrea Alicino

Andrea Alicino

project manager by day, unity developer by night

More from Medium

Journal 146 — Unity Project Development, 2.5D Shooter

Using Signal Emitters in Timeline to Access C# Scripts

2D Mobile: Loot System

How I used scriptable objects to build a powerup system