The Call of Duty Zombie remake unity tutorials continue with this video on Adding a NavMesh and pathfinding to your enemies and adding zombies into the scene. The enemies are provided free, along with all the other assets that will be used. Feel free to comment and tell us which aspect of the game you want us to do next, or any additional features you think would be cool to have in this Call of Duty Zombies Remake !

We add a custom character controller that behaves the same as the Exo Suit movements in Call of Duty: Advanced Warfare, and have a tutorial showing how to build that here: https://www.youtube.com/watch?v=AMFpOm9fFLI

If you are just joining us now, check out our previous videos in this Call of Duty Zombies Remake Unity Tutorials!

Be sure to subscribe to our YouTube channel so you get all the free assets and tutorials we release: Subscribe

hey guys welcome back to another Big Rook Games tutorial in this series we’re going through call of duty zombies and remaking it in unity3d and providing all the assets for free and this is what it’s going to look like when we are finished we have our zombies coming out of our spawn points and we have our character controller so let’s jump right back into it from the last time that we left off I did add some updates to the character controller and I release the video on what I did there how i did that i like that ended the description and i’ll provide character controller in the description as well and basically the only difference on the controller is i added the exosuit goose movements from call of duty advanced warfare i’ll show you what that looks like right now in our place screen we basically it has a double jump and a boost or a slide so you can slide I think this will be critical to use in ecology zombies will have to modify a few things so you can’t just jump on top of an object and high but i think it will add the element to the series and especially in a small map like this we need to use the height of the map as well so we can get more out of it so today we are going to add zombie enemies into the scene and we are going to spawn them at the spawn points that we created last night we are going to add a nap mesh to our scenes so that the zombies can navigate around the scene when they’re following you and last fuel instantiate zombies into our scene using a timer and randomizing their spawn points so first let’s grab the zombie asset that we are going to use we have a video on how we build the zombie asset and currently it has a walk and an idol will add more states to it for the animation but right now I’m just going to pull the prefab directly from that other video so here’s on the asset from the other video if you pull it into the scene you can see it’s a basic zombie in the tipos in there is an animation controller to put onto zombie that will control his idea and walk speed or animation rather so if you drag the zombie animation controller into the characters animator controller and push play you should have a default state of idol and you can see he’s just I all right now does have a walks information as well next we’re going to add a nap mesh and bake it into our scene so to do that you want to open navigation window which go to window and navigation and it will pop up and click on the baked tab at the top and what this does is creates a map for where the player or whatever another agents that you put into the map it tells them where they can go and how they can see Q’s so it will walk around items that are too tall to walk over and it finds the best path to the player that it’s looking for doing this is really simple if you go into the big tab and the radius is how far away from walls that an object can get . 25 is probably find height is how high of open path must be for an object to go through it so this is important in our case because we want the zombies to be able to walk through the spawn windows so right here it’s less than two units so i put that 1.5 you’ll see how this affects the map instead and then the step height that is how high over an object that the nav mesh agent can walk right now I have it at point nine so that they can walk over these ledges and all you have to do is click the big at the bottom right and once you click that it will show you a nav mesh map and you can see that it goes around the walls and it shows the pads that you can take you can see it has new areas on any flat surface and it connects those surfaces if the step in between the surfaces is less than $OPERAND . line so they’ll be able to walk up the stairs and they will be able to walk through the windows in walk over the gaps that we see in the scene so now we just need to tell the enemy to seek the players we’re going to add a script to the zombie that we imported so in the prefab that you have you can create one easily by dragging the zombie in the scene down into a folder we want to add a script actually first let’s add the nav mesh agent so in your prefab click Add component and you can just search for have and you have nav mesh agent and there’s a couple properties here that are important basically it will put a capsule Collider around your object and you can see the castle kleiner around our zombie here it’s a little big so we want the radius down 2.2 . he works the speed they’re gonna be walking pretty slow . 25 and you can mess with that whatever speed you want them to be up the height going to drop it down a little bit 1.5 and now we have our no mesh agent so now we can tell through scripting you can tell the enemy to walk and seek the player so next we’ll add a script to the zombie you add component search for script and I doing a c-sharp script i’m going to name an enemy controller double-click that bring up monodevelop then we have our empty script here now in the future this will get a lot more complex but today we’re just gonna have the enemies seek the player so we need a reference to both in that mesh agent and player transforms we know where to go so i’m going to add nav mesh agent now and transform player position and then i’m going to change the start to awake and we’re going to reference both those variables so we have our navigate component now mesh agent going to add the player position equals game object that fine game object with tag player that transform and if you haven’t named and if you haven’t changed the panic of the player object it’s pretty easy just find your controller and up in the inspector click the tag player so in the update function i’m going to have them seek the player and later we will put this in the if statement to determine if the players alive or what state the zombies in so it’s not always seeking but for now we’re just going to see and to do that you access the nav mesh agent variable and use set destination and simply put in the player position so we use our variable that we have it takes a vector3 so put in the player position position and this might be confusing so I’m going to take out to put the position part of the player so we just have player . position make sure you change all of those so now we have the update function telling the nav mesh agent to seek the player and that’s all we need to do for the model to move in our scene so if you save that and go back to the unity scene and click play you should see the zombie seeking the player now next we’ll add animation so it’s walking so if we open the objects animation controller you can see that there’s two states in here idle and zombie walk and in the transitions between them we have a condition where speed is greater than $OPERAND . one so in our script we just need to tell the animation controller when our speed is . one or both . one so if you can transition to the walk animation going back to our script we need a reference to the animator and I’m going to assign that in the awake function get it in parent you want the animator and in the update function we just need to tell it to update the player speed in there is a variable inside of a nav mesh agent that is accessible called velocity so we can determine if the agent has a velocity and then set the speed on our animator controller to that value and make sure that the animation is going when it’s moving around so i’m going to access the animation controller and you’re going to set float which is our speed and for the value of our speed the yarmulke move in the X and said directions so if the zombies moving in either of those directions we want the animation sugar
so here I’m going to set the value to the velocity now . velocity then we have
access to the x y&z and we want to know if the X or Z is positive so I’m going
to add both of those together to get one float then we’ll know if it’s moving in
either of those directions and because the exes you can be negative i’m going
to take the absolute value of each which is math f . abs and add them together
now if we go back to our scene we should have an animated zombie or the walking
animation when he is moving so now we have our walk innovation you can see he
is above the floor by noticeable mouth and that is one of the problems with the
navmesh so for now we are going to add an offset to the nav mesh agent i’m
going to set the offset to native 0.1 if we hit play
we can see the enemy seeking the player
and there’s still an offset on the player will have to fix that but you can
see I believe a walkover cars people walk through these gaps and any part of
the navmesh that you see in the editor you can walk and should walk up the
stairs come get us up here so it looks like it’s working for the most part
right now should walk back down the stairs and now we just need to
instantiate each of the objects into the scene at the spawn points that we
provide it in the previous tutorial we have three spawn points if you remember
going back to our game management object we have a script there that has our
spawn points so here is our script from before we need to add a reference to
ourselves the enemy which we can include in the UI just drag and drop the Dom
that we have into the script so it knows what object to spawned we already have a
response on the function and i’m going to add three lines of code here and we
have one line that picks a random spot . out of three spawn points that we
selected the next we have is our instantiate call this will create the
zombies at the point that we specify which is the second field in the third
field is the rotation which you don’t really care about so I just put the so I
just put the quaternion identity there and we have a zombie enemy that is our
model that we’re putting in and lastly we want to tell it how many zombies have
fun in the rounds we increment this variable here and so when the amount of
spawned enemies reaches the reaches the enemies that we set in the round it will
stop spawning with this school-sponsored enemies in our scene and they will all
follow the player so now that we have our script go back to unity and in our
game management script you can see this on the enemy needs to be assigned
so in your prefabs forever you put the prefab just drag and drop into that
script so now when we hit by it
we have our one’s on me that was already there and we have zombie spawning at our
spawn locations we do have one small location up there
I don’t know how that’s gonna work looks like the drop is too far so it won’t be
coming down but he’s still spawns and follows us around
so now we have our zombies and one last thing I’m going to do is add a capsule
Collider to the zombie so that the player can’t just walk through the
models of the zombies so if you go back to our prefab and had a capsule Collider
and manipulate it so it fits the zombie character model that works pretty well
we have Center why that one radius . to in height 1.7 so back in our scene we
can see that they’re walking too fast
so you can change the speed on the nav mesh agent so it was change the speed 21
and they’re still floating quite a bit above the ground so we’re going to
modify the navmesh capsule little bit and also if you click on the navigation
tab and you can see that the navigation didn’t line up with the map that we have
so i’m going to change the base offset and negative 0.15 if you click on the
navigation panel you’ll see that lines up right at the top of where that meshes
and that message is imperfect so there will be a little bumps here and there
but for now it will do well for what we’re trying to do in the speed is a
little off so i’m going to go back to my pad and i’m going to set the speed . six
and just want to make sure that the speed is synced up so when they’re
walking it doesn’t look like their feet are moving on the floor so that looks
pretty good
we have his own use we have our new animation controller bird outside and we
have our spawn point set up correctly i will probably move the spot . up here
because those guys aren’t going anywhere unless we added an extension to the
ladder and the stairs and just remember any changes that you make into the scene
you’ll have to read bake that nav mesh in the next tutorial we’re going to be
adding our weapons so we can do some damage to the enemies but that’s it for
this unity tutorial if the video helped you guys out be sure to LIKE and subscribe
thanks for watching guys see you next time.