Project Description

Download FPS Kit
Subscribe

Title: Call of Duty Zombies Remake Unity 3D Tutorial: Part 8 Scoring System and Player Damage Exo Zombies
Platform: Unity Tutorial
Length: 14:17
Difficulty: Beginner (3/10)

Call of Duty Zombie Remake Unity 3D tutorial for beginners!
Our take on Exo Zombies!

The Call of Duty Zombie remake tutorials continue with this video on adding a score/ money system as well as player damage and death. The fps kit is FREE to use and you can add it to any project that you have to control arm animations and gun camera controls. 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 ! Still debating on making Exo Zombies that would be able to follow you around using the same exo movements, but that will be later.

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

DOWNLOAD FREE FPS KIT (CSharp unmodified): Download button on the left

Download the new PlayerController (Includes modified FPS kit in csharp and exo suit boost movements):
http://www.bigrookgames.com/files/PlayerFPSKitCSharp.unitypackage

Our take on Exo Zombies!
Call of Duty Zombie Remake Unity 3D tutorial for beginners!
Unity 3d for beginners.

so now we have a player damage functionality in our game and we have our scoring and cash management hey guys welcome back to another bigger games tutorial today we’re going to be finally going over player damage and enemy scoring what you see here is what will be the result of today’s tutorial we have our points that you can see in the bottom left-hand corner i added a money in score variable and then we have any damage that is applied and you can see the help going down each time we don’t have the animations yet you have those later but we will have the damage element added today so let’s hop back to where we left off last time to get started and here’s our scene where we left off last time for the FPS get that we have been using for this series if you’ve been following along you know that it was in JavaScript and when I was implementing a lot of the scripts it’s very difficult to implement some of the variables and access some of the variables in between scripts due to the way the unity compiles the scripts because they will compile the c-sharp scripts first and then the job javascript scripts so many variables that you have in JavaScript you cannot access through the c-sharp scripts without doing kind of a hack I didn’t want to do that because I know a lot of people that are following these are beginners and complicate things so i have taken out all the JavaScript scripts and replace them with see sharks groups is much easier to understand where the variables are accessing from one script to another is the description field I’ve added the new FPS kit it’s very easy to replace the old one just go to your player in your hierarchy and just delete the entire player and then for the new FPS kit that i have provided in the description and when you import this just add a player right back into the hierarchy you can get started from where we are right now I hope that makes it a lot easier on you guys and I feel like csharp is a lot easier to understand and follow so we’re going to be just doing csharp scripts now so there’s no confusion so the first thing we’re going to do is to add a point system to the game and what we want to do here is go into our game management object go into the game management script so here we’re going to add a couple of variables to hold the values of our score in our money since it will have in money inventory type system and here you’re going to put stuff in player store 0 and Static player why we may be static in this case what a static variable is a variable that belongs to the class and not the instance of an object so when we want to access these variables we can call out the class and other scripts we don’t have to have an instance of this class to to access these variables so this makes it easier to access these when you only need one set of the variable in the game and you can access them from anywhere you don’t have to call an instance and now that we have our two variables that will hold our data for the score in the cash let’s write a function that will draw it to the screen we’re going to use this function void on GUI and what this does is automatically draws what you put in this function on the screen and we’ll call it automatically from unity and the first thing we need to do for this is defined a skin we have a we already have a skin that we can use we will add that in a second and then GUI style this is the style that the character will be printed in and this is inside the my skin variable under the custom styles alright at a relocation 0 and that’s what this is so we need to define what my skin is we haven’t done that yet up here with public you I skin my skin and then we can reference that in the unity ever going to copy and paste these save time but next we want to draw the labels on the screen and to do this we use a function called GUI that label and that accepts a rectangle and the rectangle is the location on the screen where you put this so 40 is the x-coordinate work starting height- 80 is the y-coordinate and then sending coordinates of 116 this will put this in the bottom left-hand corner of the screen we have scored and then after that we want to put the player score that we defined up here into that as well so it shows our score in real time and then we’ll do the same for cash i just put a dollar sign player cash end up here I’ve got to capitalize the s next want to create a function that we can access to add points to our players for a player cats i’m going to make a public function here public void add and i’m going to give it a value that we can put through the function so here we are going to add layers plus equals great value and the same player cash and the difference between players for player cash will be cash will subtract when you buy weapons off the wall in to score will stay the same throughout the entire game and because we want to access this function through the class and not through an instance through public static here for the same reason that we put static in front of the other variables so go back to your scene and in the game management under the game management script we have my skin we need to tell it which video is going to use there should only be one in the projects double click that and now when we press play it should show up on the screen in the bottom left-hand corner now we have money and score the next we need to tell it how to implement those when we get hits and kills so open up your enemy controller script which will be on the zombie prefabrication click on the script and it will automatically open and we want to tell it to add a score when it gets hit so down in the 5 damage function we want to tell it to add points so first I’m going to define a variable that has the value of the point point value i’m going to give it 10 so now when we apply damage to the enemy we want to give the player points and we don’t want the player to points if the enemy’s dead on the floor and shoot it will still do a blood effect and this will be called but we want to do it inside of this function which is if it is not dead yet then let’s access static variable that we created you can just type the management add points and so will send the point value over to the game management script and add points to our static variables so now if we press play and go into our scene we should get points when we hit and you can see our points been up to 30 in our Cashman up to 30 so now we have the points working we can add player damage from the enemies and to do that first we are going to calculate how far the enemy is away from the players we can tell it when to start thinking about attacking because we will have a innovation that plays for the attack and we want the damage to be applied when the animation hits the player or wind up here is to hit the player so we’re going to set a timer for the attack and apply the damage when it’s close to the player for a certain period of time inside the update function where we have the if statement if I live or if not is that we are going to calculate the distance and that can be done by using the vector3 distance function and the two points we are going to use our brand for position the position of the enemy and the player that will return float value so i’m going to put a variable up here public float time to hear i’m going to quit if this less than three we’re going to start attack time and we implement this by the find and then I’m going to add an else if attack timer is greater than 0 we are going to decrease the attack timer by twice the speed that increases in and what this does is if we are outside of the range of three then we are going to decrease the attack timer until it is below zero and then set equal to zero to reset the attack primer because we want to reset it if we run away and they come back and that will take care of our timer so we need to tell it when to apply damage to the player and to do that I’m going to create a function would attack here we will have a statement if attack timer is greater than any time to attack then we are going to apply damage and here we will have a sound to indicate that the player got hit so we won’t forget to help us out later so if we’re ready to attack we want to set the text back to zero so next I’m going to add a function that tells us when the collision of the enemy and the player occurs and this function is called consolation state this will be called every frame that the collider of the enemy and the choir of the player are interacting with each other so in this function we have if collision info which is what is passed to this function and that is what it collides with if collision infotype game object tag equals player which is the tag of our player object that we want to call the attack function that we have and when that function tells us that we are ready to attack we can send a message to the player to call the player damage which is a function that calls the player damage function of the collider so if you’re wondering why we’re doing this because we want to call this when you’re in contact with the player when we collide with the player it will call this function we need to change this function to a cool until it when it is ok to apply the damage to the player so in the function if attack timer is greater than time to attack which means that we can now apply the image player to return and if not return false so when it calls the function and it’s ready to apply damage it will return true and we will call the function send message upwards and player damage will apply the damage to the player third function is to send message options which just means that it has to have his player damage function in the object that we are colliding with oreo with growing hair so now let’s go over to our player damage functions see what’s going on there inside the player damage new script you will find the player damage function that we have here you can see we have 11 input it’s the damage and it will apply the damage to our hip points for us and calculated we should be done so now if you press play and we go next to zombie it will hurt us by 20 and if we do that enough and we can’t control how long it takes for them to hurt us it will take away all of our health and we will die so now we have a player damage functionality in our game and we have our scoring and cash management so next time we will be jumping in to putting our board animations up I know you guys have been asking what we’re going to do that we’re going to report innovations in the next tutorial and follow that one up implementing the mystery box in Taurus II and throwing the guns on the wall we combine two guns and then we will continue through the series until we have a complete clone of call of duty zombies that this video helped you out remember to subscribe and hit the like button and helps us out a lot and it tells us that you’re interested in keeping the series going and if you have any suggestions or implementations that you want to see in the game let us know in the comments below and as always thanks for watching guys see you next time