Configuring Cat's Animator Controller

A free video tutorial from AbleAppsDev .
Teaching Unity Game Dev, Web Dev, Python, Machine Learning
Rating: 4.6 out of 5Instructor rating
1 course
32,237 students
Configuring Cat's Animator Controller

Learn more from the full course

Unity & C# - Build A Complete 2D Mobile Platformer Game

Learn How to Develop a Complete 2D Mobile Platformer Game in Unity C# From Start to Launch in Google Play Store

19:25:17 of on-demand video • Updated April 2022

Create a mobile platformer from scratch to launch in Google Play Store
Easily monetize your game with AdMob banner and interstitial ads
Master Sixteen Popular Platformer Game Mechanics like Background Parallax, Breakable Crates, Coin Pickup Effects and more
Create an animated 2D game character with behaviors like left/right movement, jump, fire bullets, pickup coins, crush enemies, water splash and more
Design/Update levels 10x faster using my Unity asset: Level Designer
Implement Level Locking/Unlocking with awarded stars showing below level buttons in the Level Select Menu
Create and work with Prefabs
Use the components of Unity 2d Physics like Rigidbody2d
Work with Colliders and Collision Detection
Understand best practices of Level Design
Create Your Own 2D Player Controller
Easily create and work with a custom binary database file
Program useful gameobjects like GameController, AdsController, DataController etc using Singleton pattern
Program enemy characters with basic AI
Create a challenging boss battle
Build & test your game on an Android device
Deploy your finished game to Google Play store
Best practices of working within Unity editor and C# scripting
Take practice quizzes after every section
English [Auto]
Now that you know how to configure an animated controller in this video, I'll show you how to configure the Cats animated controller. But before that, I'll create the following and heard animations. This was a mini challenge from a previous video. And then I'll show you a reference snapshot. Why do you need this? Because before you create something, you need to have a goal in mind. Right? This snapshot will show you what you're about to create and you can use it as a reference while you're creating stuff. And now this snapshot might look complicated, but I'll show you an iterative process or a step by step process of creating these transitions one step at a time. And very soon you'll see that using this process, you've configured these cats animated controller. So let's get started by first creating the following and heard animations. All right, let's begin with the first step process, DoubleClick sprites, actors, players and Cat now will open the animation window by clicking animation and we will attach it next to scene window. We will select CAT and ensure that the Cats default animation is showing up. And then we're going to create a new clip and we're going to call this falling. And let's make sure we are storing it in the right folder. Animations cat like so and click save the following animation is showing here. This red button is active. All these buttons are red means the recording is going on. Let's add these sprites select fall and shift and select all of these drag and drop here and let's test these samples. I think twelve should be good. That's tested by clicking the play and you know how to rectify the lubing. So let's turn these guys off, save the project, let's create another clip, call it hard and we're saving it in the proper animations folder, ensuring that the record button is read. All of these buttons are Red Heart is displayed here. Let's locate these sprites for heart and right here. OK, shift and drag and drop here. We're going to set this to twelve as well. Go to game window, click play and OK, this looks kind of cool. All right, so that's it. We have just created the falling and the hard animation. Now this cat has ideal running jump falling and hard animation's. By the end of this video, you would have created something like this. This is the controller which has been configured with transitions and state parameter values. Now, if all of this looks complex, don't worry. In just a short while, I'll share an iterative process of incrementally or in a step by step manner, creating the transitions, then assigning values and then testing them. And only once you're sure that one transition is working, OK, you move on to the next transition and then so on and so forth. And very quickly, you'll have all of the transitions configured. All right. So let me show you that process. This process is simple, it involves four steps, the first is you select the two animation states between which you want to create these transitions, then you create these transitions by creating the arrows and then you select one of the arrows or transitions and create conditions and then you test. If the transition is working in the play mode, then you simply repeat steps one to four till all your transitions are working right. So let's see this process in action now. After creating the following in hard animations, you'll have to more animation states. Let's begin by dropping the animated window here because then you can resize it and have some more visual space. Next, let me show you the reference snapshot. We have to arrange the boxes like so. So let's do the dragging. Now, let's bring the outlook here and bring the printing here. I'm going to do this a bit faster now. So this looks about right, you've got the boxes configured as the snapshot, now let's create these transitions. So here's the basic formula. Let me first tell you how I got these numbers. Zero, one, two, three. These numbers are nothing but values for this state variable, and it takes values only integer types. You can be negative or positive. So here's the first thing you can store any number I've taken zero one, two, three, because the default value for an integer begins with zero. You can have 10, 20, 30, 40, thirty five, forty seven. All kind of combinations but integers. Now, once you have done that, assign the integer values to the various animation states like option in this case is zero. What does this mean. This means that if a change needs to happen to the ideal state, the condition on the transition should be zero. And what do I mean by this? Have a look. We have a transition from ideal to jumping. This is the transition. And first, let's uncheck has exit time uncheck fixed duration? Said this value to zero save the project. We are doing this so there's no delay between the animation changes. Now, I told you, jumping has a value to this means in this conditions block. When you click the plus icon, you get this state simply select equals two and save the project. This is what I meant by saying if you want to change to jumping, simply have to assign two to the conditions like. So let me show you let me drag and drop the game view here. Now let's play the game. Watch the default animation is idle if I change this too. This is supposed to change the jumping. Right. And that's what happens. So this is awesome. Simply it back to zero. Will it change. No, because there's no transition. Back to Idol. Let's do that. You select jumping may transition. Drag the arrow on to Idol. Select the transition first uncheck has exit time uncheck. Figuration said this to zero and in the conditions select state. Here's my question. What do I need to set equals two. It's going to be zero because come back to Idol you need to assign zero. So by default to zero. I saved the project hit save and in the play mode you can watch. If I change this to two, it goes to jumping. If I change this back to zero comes back to Idol. That's cool, right? This is the iterative process I was talking about. You create transitions, assign conditions tested in the play mode and only after verifying that things are working fine, you go on to the next transition. Now, if you continue doing the same process, you'll have configured the running and jumping and jumping and falling in any state to hard animations. All right. So here's a mini challenge. Pause the video, go ahead. Create the transition from any state to hard and then come back. Welcome back. So I hope it was easy, right? You simply have to select any state, make transition, drop the arrow on to hurt, select the arrow, ensure that figuration and transition duration they have been reset like so can leave the rest of the settings as they are. And you want to change the condition. State equals negative one. Go to play mode and said this guy to negative one and you can see oh the cat is crying well so the third animation is working as well. The next I want you to click running select make transition, drop it on to jumping and then select the arrow. Here's the thing. With every transition that you make did not jump to making the other transition, it's going to clutter up the things. So the iterative process tells you to first create the transition, select the transition, then configure D has the time fixed duration like I show you and then you want to go ahead, assign a condition state equals. Let's have a look at the reference. It's going to be jumping is two. So this will be to save the project, go to play mode and you're going to change values here. Now at this point there is a valid confusion and that confusion is how do I remember all the values? How do I know that I need to enter one or two or three? Well, how do I keep track of it? And that's a very important question. So the way I do it is I use a text file. Usually I write write things on my notepad that's on paper and pen. That's easier, but you may want to do it on a notepad. You first need to write the different states. So you have Idol, you have running, you have jumping and you have falling and you have heart. Now after doing these, you need to assign values to them like so running is one, jumping is too, falling is three and hurt is negative one. So I keep this right here in front of me on a notepad. So now this serves as a reference for me in the play mode. I know that if I want to go from Idol to running, so running has won. So I simply need to add one here and the player starts running right now. If I want to change from running the jumping, jumping has to. So I change this to two and the player starts to jump. OK, it's as simple as that. So let's configure the rest of the animations quickly now. Select jumping may transition on to running, select the transition, uncheck these boxes and reset this deserve now running is one so this will be state equals one. Save the project, go to play mode. The running is going to be one so you have to enter one here. The player starts to run. You can change this to jumping, but entering to here the player starts to jump. Enter one, the player comes back to running and setting it back to zero brings the player back to the ideal state. So this is the easy way. OK, the reason I didn't show you earlier was first I wanted you to see the problem and now I'm sure you understand that there was a problem. Right? How do you remember? What are the different state values? And this is how you do it. And I like to write it down on a piece of paper so you can choose whatever feels comfortable for you. Let's configure the jumping and falling make transition like so. And we select these guys. Now, as you see, falling is three. So the condition here state equals three. Save the project, go to play mode. Now falling happens only from jumping mode. So first go to jumping. Jumping is too slow to the parachute jumping and to come to falling. Falling is three so you need to assign three here and there. The player has started falling because the player's looping. It's very easy to fix it. You double click this animation state uncheck loop time and that's it. You go back to play mode first go to jumping is two and then enter three. And there the player is in the following state. OK, we want to bring the player back to Idol. The references falling to Idol has a transition. So falling make transition idol select the transition. Once you start to do this process a couple of times, it's going to be faster and faster for you. For Idol, the state of Israel. You can save the project. We're good to go. Go to play mode first. Let's go to jumping is two. Three is falling and then from falling zero. Right. So you just saw how easy it was once you've started doing this. It's relatively all of this starts to fall into place and you'll not be prone to making mistakes, falling to running. So falling, make transitions running, select the arrow, uncheck these boxes, reset this to zero condition for running is one. So this equals one save go to play mode. So let's go to jumping and falling and from falling back to running there. Everything is working flawlessly and you may want to come back to the Idol mode. OK, you have seen the heart is also working. If you change this to negative one doesn't matter. The player can be in any state. The player shows the hurt animation. Right. So at this point of time, let me tell you all of this process that you did manually of entering these values for different animation states, this is exactly what you're going to do in the next video when you start to use scripting to make these changes happen. OK, so be very sure you understand this mental process and then join me in the next video. I'll show you how easy it is to change animations using the code.