Hi, everyone. I'm Jeremy Gibson Bond and welcome back to the Unity Certified Programmer exam preparation course. In this video, we're going to be looking at your next challenge, which is adding animation to both the enemy and the player in the stealth game. Let's take a look at what it will look like when you finish this challenge. Here I am in Unity, I'm going to press play. You can see here's my character, I'll go ahead and maximize this. Here, you can see my character; this is a character from the adventure game, that is up on the Asset Store by Unity. You can see my character uses the standard animations from Standard Assets, but there's something new here, which is, whenever she goes into cover she spins around, she creeps along cover, and she stops at edges, she doesn't stop at inside edges, but she does stop at outside edges, which keeps her from running into our robot that we animated in the previous challenge. You can see that this robot now, turns and walks, and it will turn left or right properly based on which direction it's turning. So, that's what we wanna do in this challenge, of course, they interpenetrate now and that's totally fine, it's not a problem, we're going to be adding that later to the game. Now, let's start by taking a look at the player herself. So, this is inside of the starter project, as opposed to the finished version that I just showed you. When I click on the player, you'll notice there's a lot of code over here, there's a lot going on that figures out how to go into cover and where the edges of cover are, and all this other kind of stuff that honestly for this challenge you don't need to worry about, you're more than welcome to read through it and understand how it works, but for this challenge, all you need to do for the player is work within the animator. So, here within the animator, this is the same animator that's in Standard Assets. You can see this design for a character they can jump, which is airborne and crouch, which is the crouching state. Both of those states are irrelevant for this game, so you need to turn off the transitions to those states from grounded, grounded is the normal running around, that our character does do. You can see I've added two parameters, here inCover and creep. So, inCover is checked when our player has gone into cover and is false when our player is not in cover, and then creep left or right is negative if she's moving left, and positive if she's moving right. These values will enable you to set up a new state that there's a nice space for it right here, that is going to be an inCover state that your character will go to when inCover is true and exit winning cover is false, and then within inCover you should set up a blend tree, that allows you to use the creep value to set what her animation looks like creeping left and right. So, here, if I double-click on grounded, you can see a blend tree inside of grounded. So, that's where the blend trees are, and that's a good example of a blend tree. So, that's the animator on the player character. Now, where are you going to get these animations? Well, we have pulled some new animations in. If you open up adventure player, cover animations from Mixamo, there are three animations from mixamo, there are cover, idle, cover sneak and right cover sneak, so left cover sneak, and right cover sneak. These are all set up for your player already, but I just wanted you to know where they were in the project hierarchy. Speaking of animations, all the new animations for the ACS17 are also by Vladimir Tim, the creator of the model. you can see all of them here in the animation folder. Now, the enemy is somewhat different. If I select the enemy, I have to go into the enemy and click on this ACS17 to get an animator. You can see in this animator that there are a lot of different states that we could use on the ACS17. But, the only states that I'm going to use in this challenge are ACS_Idle, which is what we're going to do when the body is not moving, when standing there waiting at a waypoint. ACS_Walk which is what we're going to use when the body is walking forward and then ACS_TurnLeft and ACS_TurnRight, which are the left and right turn, respectively. The difference here, is rather than working in the animator as you did for the player, I really want you to execute this entirely in code. I'm going to show you a little bit about how we're going to do that. So, the first aspect of what I've added to allow you to do this is a little bit on the enemy nav script, that tells us the turn direction. This is calculating using a cross product and you take a look at how it works in there, but turnder is negative when we're turning to the left and positive when we're turning to the right and zero when we're not turning at all. So, you can use that to determine which way to turn when the mode is set to either preMoveRot or postMoveRot. When the mode is move, we should be walking forward and when the mode is idle or wait, we should be in ACS_Idle state. Now, that animation is actually going to be controlled by the ACS17 Animation Manager Script, that I've placed onto the ACS17 child of enemy. One thing that's cool here if you think about the structurally, is say you replaced this robot with a completely different character, that still use the same navigation to patrol into waypoints and stuff, but we've replaced what it looks like. This way, we can replace the animation and just base that animation off of the enemy nav script rather than having it embedded into the enemy and have and having to change it when we changed out the model. Looking at this, you'll see there's not much here in the Animation Manager yet, but I do suggest that you use anim.CrossFade("ACS_Walk", 0). So, let's break down this method, anim is a link to my animator, and you can see I've required component type of animator up there. Then, we can tell that animator to crossfade to a specific named state like ACS_Walk and then the zero there is a crossfade time of zero. If we set the crossfade time to zero, then we can pass this to the animator as many times as we want and if it's already in that ACS_Walk state, it'll just animate nicely, and that's what you see in the example solution that I have. Your bonus challenge, for this time is to figure out how to make that zero into another number, so you can actually blend into the different states. But, what that's going to require, is going to require you to only call this once to start the transition to the new state, and not call it repeatedly because if you call it repeatedly with a number there other than zero, then it'll just continually start that transition and it will never actually complete and finish the transition and move completely into the new state that you're trying to cross fade into. So, that's it for this challenge, there's a lot more that has been added to this project. Again, you don't really need to worry about it here, but if you want to you can go in and see how I've started to create the stealth player camera that will actually track the player, and in later challenges what will happen is when she's uncovering, she's moving close to an edge just like Metal Gear Solid, it'll actually zoom in to allow us to peek around the edge and cool stuff like that. But, again, you don't need to worry about that too much right now, is just something fun to take a look at if you feel like it. All right, so I hope you enjoyed this challenge, and I look forward to seeing you in the next video. Thank you.