Animate the 3D Model by Using Animator- Game Dev Series 68

Objective: create different state of animation in Animator.

Animation is what can bring our 3D models come to live. In Unity, we can even switch between different animation through states. Which is the basic animation function in Unity.

In this article, we will create animation state to make our character animation switch between idle and walk.

Intro of Animator

To create an Animator, we can simply right click on Project and select Animator. Double click and it will open the Animator window.
You would see some default states have set.

Now we can drag in our animation from Project. In here, I would drag in Idle & Walk animation.

If your animator has not set the Idle as default state, you can right click Idle and select as default.

Now we can set the state transition to our animations.

Set the transition

Right click on the Idle and select Make Transition, then click on Walk. It will create an arrow from Idle to Walk.
Since our state should return as Idle from Walk, let’s do it again from Walk to Idle.
It should looks like this.

With transition, we will need to add a parameters to it. Click the tab Parameters on the top left of Animator tab and click Add button.
In here, we will use bool as parameter.

Let’s assign this bool to both of the transitions.

Don’t forget to uncheck the Has Exit Time.

Now our animation is ready, we can assign it to our Player.

Assign the animator

Select the 3D model of our Player and add an Animator component. If the model is a child of Player, you should add the component in the child.
Then drag the animator that we create into the Animator component.

Next, we will make our Player to access the Animator in script.

Access the Animator from code

Open Player script, we need to add a variable to access the component from child.

In Update(), we will make it set the bool to true when the Player has a destination from our mouse clicking. We can use NavMeshAgent.remainingDistance in here.

Save script, now our Player should have Idle & Walk animation when playing!




A passionate gamer whose goal is to work in video game development.

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

Recommended from Medium


Coinhub | Tutorial on Rarity

Building a Tendermint & Cosmos SDK App (Part 7): Testing the app through the CLI

Looking back on our intense monthly task. TBS 📖

Decorators in Python: What you need to know

CS373 Fall 2021: Week of 13 Sep — 19 Sep

Why Programmers need creativity

Elephant in the Room: Database Backup

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
S.J. Jason Liu

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

More from Medium

Creating Elevator in Unity — Part 3: Moving Elevator.

Day 103: Creating A Ledge Grab in Unity Part 1

Creating An Advanced 2D Player Controller Without Any Unity Components! (Part 1)

Learning Unity — How To Make A Loading Screen