Develop a 2D Shooter game in Unity | SandS Arts | Skillshare

Develop a 2D Shooter game in Unity

SandS Arts, Game developer

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
13 Lessons (2h 33m)
    • 1. Introduction

    • 2. Project Setup

    • 3. Player Script

    • 4. Setting up Spawn Manager

    • 5. Wave Indicator

    • 6. Reducing Player's and Zombie's health

    • 7. Spawning collectables and randomizing zombie's scale

    • 8. Spawning particle system and a boss at the end of a wave

    • 9. Building the game for Windows,Linux and Mac platform

    • 10. Mobile controls and building the game for android and iOS

    • 11. Implementing Applovin Ads for our game 2

    • 12. Where to support me

    • 13. Where to ask doubts


About This Class

Hey game developers !!!
Before taking this course make sure that you know the basics of C# programming.
I will teach all the programming things in detail, if at all you didnt understand some part of the tutorials you can ask me in the discod server i will make you understand.

We will be creating so many things in this course like enemy spawn manager,wave indicator ,health bar ,cool effects ,spawn boss at the end of a wave and more.

Join our discord -

After completing this course -
You will be able to develop more than 50 types of 2D Shooter games !
You will be able to develop your own game !

Download the player here -

Download the backgrounds here -

Download the zombies here -


1. Introduction: Hagan develop owes So Shankill from Sand Sharks. In this course, you will learn how to develop a complete story shooter game in unity. After completing this course, you will be able to develop so many truly shooter games. Immunity. You will learn so many things related to game development. I'll explain all the things that I'm going to teach in the schools before taking this course, Make sure you know the basics off. Seize up like what's our data types on different types of data types? What are variables? What is looping and different types off looking statements like for loops, etcetera. If you don't know just with that YouTube and watch the basic key shop it Oreos in the schools will respond enemies at some random points, we respond collectibles. When some zombies die like health increaser, we will randomize zombie scale so that every somebody will have different size. We will create very vindicator health bark on many more things. Who spawned Boss? At the end of the game, we will also spawn some cool particle system. When bullets collide with something, we will implement up lovin acts for a being. We will build our game for Windows Mac, Lennox, Andrada and I always You can alter anything, for example, the number of zombies to spawn in a particular way, the type of boss that should be spun in a particular way. The health off, the zombies, the damage that the bullet does for a zombie, this pond right off the bullets on many more. You can create thousands off levels on different types off kings. I'll make you understand the concept that I teach in the schools. If you find any doubts and this goes for could reply, you can ask me in my discourse over it is just the up where we can chat similar to what's up. You can join my discourse over by clicking the link, which is available in the description. Join my discourse over by going to discord up dot com. Click on the button on the left button. Select. Join us over on Entered this link 2. Project Setup: Hey, game, develop ALS. The Sankyo from sank sobs This is the first video on location off duty shooter game in unity in this video, really important sprites that we'll be using in our gay. We'll set up the background. I will tweet animations for player as the last enemies on will treat Animator Control owes . Let's start by creating a unity project. Click on you. Let's enter the project. Name us truly shoot again. Make sure you have enabled the truly struggle because this is the tour again on hit Create Bras it. I have downloaded three ZIP files from the Internet, which contains the strides that we'll be using in our game. You can download these files by visiting the links. It's another level in a text file. Call sprites in the Project Files section. These files are observed files. In order to open them, you need to either install Vinger. WinZip are 70 now. Let us open the first zip file, it say's free Halloween to became backgrounds. There is open the pantry folder. The third game background layers on will import the first force price. You can't just drag and drop directly into the Unity folder because it pops a panel. Er, they followed us first. Drag it into the desktop in the assets Holder will create a new folder Call it Backgrounds On Will Drag and Drop all the sprites into the folder. Let us delete all the sprites from Modesto on will open the second Zip file. The Pansy folder. I'm glad on drugs, but this fooled us into the restaurant. Well, upon the female forger on, we'll delete the island nation because the never they zombie spawned, we'll play be walking animation. Therefore, we don't need the I language, the hostility I land mission off the males on BS will on. Then we'll import days to fold us inside. Unity here will create a new folder, Call in some bees, and then we'll drag and drop both off this folders into the Zombies folder. Let us deal. It dates from the desktop well upon the third Zip file, click on the second fuller real stocks like P and G exports on Dragon Drop the first folder into the desktop. If you open this folder, you'll see two types of sprites. The 1st 1 is the short oven. On the 2nd 1 is the larger one. We'll be using the shortest right in our game. Therefore, let us delete all the sprites which says at two X let us select all of them on well lit them. Let us create a new folder inside the Assets folder. We'll call it player. We'll be using the island mission, our core player. Therefore, let us drag and drop all the files US rights, which has I lame on it on. Then we'll be using the difficult animation, therefore, will drag and drop all these rights inside a folder. Next, we'll be using the heart animation, the fire animation here we don't need walk fire, don't animation. They followed us till it all this price Which spacewalk? Fire down. We even don't need jump fire animation They folded to Cilic. The sprites on will deliver that. Now we'll import all these files inside the folder on the final animation that will be using in our game tasty walk animation. Therefore, let us try and rob the sprites. It says only walk now let us create a new fuller on. We'll call it collectibles. On inside this folder. We'll import to slides. They followed us open the third zip file. The second pointer on the folder would say its massive weapons candy on. We'll drag and drop the uranium on Fat Boy bomb inside the desktop on will drag and drop this two sprites inside the collectibles full. So why did being vote? These two sprites, whenever some zombies has been killed by the player we spawn some collectibles like the health, the list vinyl player collides with the health. That is when a player collides with the uranium. Our, despite his health, will be increased by. 10 are 20 according to the script. On whenever the player collides with this bright, we'll add extra bullets for this weapon. Now we have imported all the sprites that many for game. Now let's treat a background we take on the backgrounds folder. Will that on drop all these rights inside the Iraqi? Now he fluidly you notice that the background has not been skilled according to the screen size. Therefore, in order to fix this, let us create a canvas Well, said the random oh to screen space camera on will drag and drop the camera as we want to scale. The sprites, according to the camera, are the stream size will drag and drop all the sprites inside the canvas on will set us kill moved to scale with screen size because we want to scale these sprites according to the screen size are the camera says. Now, let us select. All these brides are real. Skill them till it fills the screen size like selecting moon. I'll start it scaled to 2020 and 20. I would write it over here. We'll set the order in layer off these three strides to one because we want the sprites on top off the first right as its order Only a zero this bright will be below the sprites with has ordering layer one all greater than zero. Now we definitely we noticed that the background has been scaled according to the screen size. Now in illustrate animations for our player as well as zombies. First will create animations for player. The 1st 1 will be the definitive animation. There is ragging. Drop all the sprites, which has defeated name on it into the Iraqi. If you drag and drop multiple splits into the hierarchy, unity automatically know study, according an animation. Therefore, it box of this window will create a new folder inside the assets will call it Animations On Inside This folder will trade a new folder. We'll call it player inside. This will say this animation asked. Defeated Now, as you created the animation, it automatically creates our animator controller. We're just distinct Let us delete the enemy to controller We create a new animator controller I will call it player now let us open the animator window and we'll drag and drop the different in animation s Click on this bright on will drag and drop the player and me to controller into the country Knowledge the Straits Remaining animations for our players Now we can read and drop the sprites on top off the place Right Because we're adding the animations for the same animator controller with display animator Controller Let us say this animation US Fire on now, As you saw the animation called Fire has been added to the same animator controller called player Let us do the same for the remaining animations. Now there's great enemies since for zombies rules I can drop the attack animation record A new folder inside animations I will call it Zombies Inside this folder will treat a new folder on Call It Seeming Zombie. He will say this animation as attack, we'll click on the animations Somebody's female somebody. We'll delete this and meet a controller because we don't want the an emitter controller name as attack recruiting you animator controller. We'll call it females on me, and now we'll drag and drop the animated controller inside the controller. Then you drag and drop the attack animation inside the animator control. If you don't have this window, just go to Window and Click Animator, record the remaining animations and create the same for the man. Zombie will cut a new folder. Call it Males on Me and inside This will say this attack. Now let's click on the male zombie on We'll delete. The ultimate controller will trade a new animator controller. We'll call it means on me on. Then we'll drag and drop the attack animation for this man Zombie In orderto add animator controller, we need to add a component called Animator I know will drag and drop the males on the enemy to control incredibly meaning anime too. Well, you're the remaining animations and now we are created. The animations for player as well. Last the zombies. We'll select the male and female zombie who said this scale 2.5 point side on points. We can even radio that size 2.3 point three on point Lee. Now, if I drag these zombies down, you notice that the zombies are looking behind these two sprites. I mean these two sprites. This is because it's Arlen Layer, they said to one on the zombies and Player Order in Layer is set to zero. We want these three strides to be on top off the background. Therefore, will set order in layer to To will rename this two player on the 2nd 1 to Female Zombie, the 3rd 12 Main zombie. We're still radios the zombies size 2.2. And yes, I think this enough will add box colliders toe player as the last zombies, as this is a truly game unit to Add Box Collider Trudy. And now, if you hit on the player, you'll see let her box collider has been added on this box school either has not been skilled, according to the player she delivered, a slick Eric Collider on will decrease the size off the collider. Now let us decrease the size of the box Kaleil off form a zombie on. We'll do the same for the females on me. We'll select the street sprites well at a rigid body to re competent. Will set the gravity scale to zero because we don't want this sprites to experience gravity and fall down will set me collision detection to continue years because we want to detect the collision continuously. We'll click on Constraints on Will free STI rotation because they don't walk the sprites to rotate will create a new folder. We'll call it pre fabs and then we'll drag and drop the player Females on me on main something. Now let us really these three sprites, I will say they've seen us game. And yes, we have set up the project. If you have any questions regarding to this tutorial, you can ask me by joining my discord server 3. Player Script: Hey, game developers to some kill from San starts in this video will enable the player tome around the scene on shoot first. Let's go to pre fabs on will drag player into the scene in order to enable the player toe move around the scene and suit when you to code. They followed us our A script called Player brokered in your script on related to the player. In order to enable the player to more on the scene, we'll be using rigid body off the player, which is distinct. First sale rated body. Julie will call it RB on in the start. Matured will say RV equals get competent, rigid body. Judy, take what Just us. So whenever we start the game first, the things inside the start mattered will be executed. Here we are creating a variable R B off rigid body judy competent. Therefore, it is eternal value we need to assign a value for they are be variable. Therefore, in the stock matter, resting R B equals get component rigid body to be so anywhere we start the game. The rigid body attached to the player it's interesting would be assigned to the are being there. But it is not that whenever you write this line off court, always the rigid body of the player will be assigned. No, it depends on the game. Object to with your script has been added. So now here I have other descriptors to the player. Therefore it gets the rigid body Torrey competent off the player. If you added toe empty game object which has a rigid body tooty on the player script, this rigid body to re confident will be aside toe this variable which is our baby here regret our public float will call it speed and then we'll create a vector to call it more position. This variable is the speed off the player In the app Nick matter will same opposition equals new rector to Then we'll say input dot Get axis horizontal. Well, multiply it with speed on a little multiplied with time door delta time As Vector two takes two arguments, the 1st 1 is the float X on the 2nd 1 is float. Why we passed the second argument as input Look, get access article on will multiply it with speed on then Time dog at the time in the wide fixed up next method will see RB not more position. The position only takes a single argument. There is a position to which we want to move the rigid body, therefore will say RB not position on, then will I move position to the current position off the rigid body? We are multiplying. This which time? The delta time, because different pieces are different devices, has different frame rates. Therefore, we need to multiply this with time door delta time. If we take a look at the documentation, it says If you add or subtract to a value every frame, chances are you should multiply with time dog all the time. When you multiply with time, don't tell the time you essentially express. I want to move this object. 10. Meet up a second instead off 10 meters for free. So we need to move objects per second on not poor frame, because different devices have different friendly in simple words. If you multiply the speed with time, don't tell the time the player will move with same speed on different devices. More position is off vector to say that I, as we had declared a book, it takes two arguments. This is the first argument on this is the second argument input dot Get access horizontal. You can see that by going toe direct project settings and input. Over here, you see something called access on the horizontal one. Here we are accessing input. Don't get access horizontal, which means we are getting the input from the axis. God horizontal input, not get access. Horizontal returns Positive one if we are presently positive buttons, which is still right Arrow key on Denny button. Egyptians negative one if we are pressing the alternating negative button are the negative button, which is the left Iraqi or the Heikki. It returns zero. If we are not pressing any off these buttons, you can change these buttons instead. Off A and E, you can enter que Onda said. It's based on your veg, but I am not going to change the skis on the same forward tickle import dot Get access Article. Britain's positive one. If we are pressing the positive buttons, that is publicly only a parakeet. Your students negative one. If we are presented down Arrow Key RDS button And it didn't zero. If we are not person, you of these buttons. Here we are getting the powers online. Put on the vertical input on this is the speed off the player. That means the speed in which the player has to move and you know why we have multiply it with timed or delta time. That's consider speed as eight on Let's Considerably oppressing the deaky with Britain's positive one. Therefore input. Don't get access horizontal willed it and positive one one into 88 on. Consider this whole value. Toby five on over here looks considerably a proceeding w key on. Let's consider the speed US aid itself on. Let this whole value be five considered this as the initial position off the rigid body. But this one comma too rigid body contains our in built function called more position. It takes only single argument. That is the position where we have to move the object. Over here, we are saying ibid. Our position plus more position. RB dot position just returns the position off the object, which is one comma two on. We're adding more opposition to it. This was the initial position. As I said, let's consider this value to be five on this value. Toby fight for Over here we're adding five for the initial position off the rigid body. Therefore, it becomes one less five on two plus five. Therefore, the final position will be six comma seven. This function mostly object from here to a new position that is six comma seven that a service handed back to unity. No Benito. Assign a value. So the speed variable we'll say a desk fight on will hit play on. Now I can move a player by using W A S and Dickie are the arrow keys Cool. So here you notice our problem. Whenever you press the aching that is stools your left hand side. The player is not turning toward the left. Let's fix this will go back to the script on in the update matter. Well took if input not get access. The horizontal is greater than zero. It's a transform that you either Angus equals new record three zero comma 1 80 coma zero. Really copy the code. Well based it again instead of greater than zero. Will say less than zero if input don't get access. Horizontal which returns values between plus one on minus one. Whenever you press the A key or the left arrow key. It returns minus one. Whenever you press to Dickie or the right elope, it'll don't spaz ity. One. If you're not pressing any of the case, it will return zero as we want to change the players rotation. First, we need to access the transform, and then we should access the rotation. Therefore, I have access to transform, which actually means the transform off the object to which the script has been a taxed. We're accessing the transform, and then this rotation in vector Form A. Therefore B A senior Wranglers, as this contains three values. We are saying New Vector three and we are starting changing the X y and Z notation we are talking. If we are pressing, the deaky are the right arrow key, which little? It's positive. One positive one is greater than zero. So here, whenever we oppressing the D key or the right arrow key, we'll change the rotation off the clear 200 and zero, that is, we are setting the exhortation to zero wider day Santo zero on Z rotation to zero. If the change d why value to 1 80? We noticed that the player has turned worse. The left side. So when will we press the A key? We want a player toe. Don't do left if we are pressing the A key or the left Iraqi insurgents. Negative one inanity. One is less than zero. Therefore, it executes this school. We're changing the rotation off the player 201 80 0 Whenever we press the A key or the left out a key, we are changing its rotation to zero 1 80 0 Therefore the player has turned towards the left. And whenever we repressed the Dicky or the right arrow key, we are setting a tradition 200 and zero. Therefore, the player has turned towards the right. We can either enable or disable the flip X component in the striped renderers because it does the same job. But the problem is that whenever you create empty game, object will be using this position to spawn bullets. So whenever we enable the flip X or whenever we flip the player, the child switch house being attached to the player doesn't flip. Therefore, I'm not using flip X component over here. If your turn do player exhortation to 1 80 Even that child's position will be changed. Therefore, this ISS useful now. Now if we say this and head back to unity and hit play. We noticed that whenever we Rusty Dickie or the right Arrow key, the player will move towards writes on. Whenever we press the key, he will flip. Andi will move towards the left. Great. So now whenever we try to move the player on the scene, the player is not animating. Therefore, letters animated. We'll go to the animator window whenever we hit the start button the island nation off the player will be playing So now when I will be pressed me Iraqis all the W is on Dickie. We need to play the work animation Therefore, in order to play the animation first we need the access for the animator Confident therefore, let us go into the script We'll see animator on We'll call it Adam and in the start, metal with the Annam equals get component Animator So this is doing the same job Asked this thing whenever we hit the start button the play button the animator attached to this came object will be assigned toe the animal wabe over here. Whenever we are pressing the D or the right Arrow Key will play the walk animation. Therefore, we'll say Adam darkly as we need to play the walk Animation. Its name is Walk Itself. Therefore, I'm typing work over here. Copy the code on Well, placed it over here when it will be a pressing the a de all the left Ira button or the right IRA button. We are playing the work animation. If they saved the send it back for unity on Now, if we try to move the character, the work animation gets plead, see, But when it will be released, a button we walk animation will not stop playing. So therefore, well, right Economy, walk animation will flick make transition and then we'll speak on ill. So whenever the work animation has finished playing, it gets back to the island nation. I said The speed off the work an emission 23 You can either increase or decrease the speed values in order to alter the animation off the player. Now, if we get to play on it, we stop. The island nation gets plead. But whenever we oppressing the W and s key all the up arrow but north down arrow body. The player is not any meeting. So therefore, here the tuck. If input dot get access, vertical is greater than zero. Far and put door get access were tickle. It's less than zero. We will play the work animation, which means if we're oppressing the w key or the up arrow button or if we are pressing the pesky Audie down Arrow key were playing the work on Mission. Now, if we check this out if you pray the R key already down Iraqi are the left and right, the player gets animated on. If we stop pressing the button, the work animation gets stopped. Now let us enable the player toe fire our suit blacks. So now will be creating a new sprite on Will you, using that as a bullet? Will Toasties, right as the 1st 1 Well said. It's already layer to three because we wanted to be on top of everything else. They've already is its size and then we'll turn this color to black. Let me unity. Is that societies? Yes, I think this is enough And then I will add a box collided Tooley on a rigid body competent , I decided scholars under decks into continues. I'll first it that relation because I don't need to rotate the object on. I need to detect collision really in this two bullet in court, brief APS and we'll drag and drop the bullet inside. Now let us head back to the player script in order to spawn the bullet. First, we need a reference for the bullet. Therefore, well said public game object will call it bullet on. Then, in order to spawn the bullet, we need the position where we need to spawn this particular bullet. Therefore, bills a public transform bullet, both suspicion and yes, in the update Mentor, I took it input dot key echo dots piece. I will instance shady bullet and the bullet position dot position. Bullet position. Dark rotation. So what? This dust. Whenever we are holding the space Parton, we're spawning. Or instance she ating the bullet in the Bullock position on with its rotation. Instead, she it is a function and unity. It's is nothing but spawn. So in stance it is you're still spawn optics in unity, it takes three elements. The 1st 1 is the object that you need to spawn. The 2nd 1 is the position of alien ready to spawn This object on the third argument is the rotation. After this object has been spawned in particular position, it's rotation will be changed toe this rotation. So consider this as their bullet point. Whose position is one comma too On dissertation is zero comma one comma seven And consider this as a bullet. For instance, you it sponsors this bullet on. Then exposition will be changed to bullet point guard position. Consider this as a bullet point. This bull exposition will be attained stew one comma too on its rotation will be changed to zero comma one comma seven. As the bullet point on this bullet will be exactly at this point after spawn and then in the pier will that and drop their bullet game object no will create a bullet point. Therefore, I need to spawn the bullet in this position. 100 00 and zero rotation. I rename this true bullet provision. Now we'll drag and drop the bullet position, but the bullets are not moving. Therefore, two bullet will add a script called bullet. In order to move this first, we need e reference for the rigid body. Therefore, we'll say Rigid body Jodi. We'll call it RB on in the fixed up Need metal when say, I'll be darn more. Position the current position less vector tree dot right, well, multiply it with speed on timed or tell the time over here. Regret our public float will call it speed. This will be the speed off the bullet, but first we need the reference for the rigid body. Therefore, in the start will say R B equals get component rigid body to t on. That's it. We're writing this function in the fixed up need method because so it's extinct are usually performed in the fixed update method as rigid body comes in the physics. We are riding this line off court in the fixed up Nate method. So for the move position, we're passing the current position off The bullet on we're adding Victor three dot right rectory dot right is the shorthand for writing one common zero comma zero. So whenever we spawned the bullet in this bullet point position, we're adding values to the exposition that is in this way, as it is, victory dot right will add one comma, zero comma zero. So we're not altering the white on dizzy position. We're not only adding one to the exposition. It depends on the speed value on this value. No. Consider this as the current position off the rigid body. Then we're riding with Touch me. Don't right, minus one comma zero comma zero. Imagine this value is going to be one. If it's one, we're creating a new position. That is, we are moving the bullet from here to a new position where it's X value is greater than this value by one. Consider disaster point. It will move from here to here. I think you understood. But as this is a tool drinking, we need to use vector to dot right director, two dot right? Is this shorthand for writing one comma zero? We're not considering the position. Let us go to the bullet Repub will side of speed to one. We'll go back to the player script on here will get a public flute. We'll call it time between spot on Very well. We press the space key Louisville called according so therefore will say start courting. We'll call it a bomb. Will it over here we greet courting. Filippo is a I enumerate. We'll call it spawned Bullet on inside. This will say in return. New Wait for seconds. The time between spot And now we'll instant you. The bullet poor dissed us whenever we hit this piece key or whenever we hold this piece body and will start extorting called Spawn Bullet. This line off court will wait for some time, depending on the time between spawn value. Imagine it's valueless one. Then bullets will be instance created or will be spawned. Post Second, if it is to bullets will be sworn every two seconds on in the code. Whenever we are holding this piece button, we are calling this court E, but after calling, we don't need to call it again. Which means update is called so many times, depending on the frame rate. Therefore, when it will be a holding the space pardon, we don't need to call, according we only need to call it once on. We need to call it again whenever we have spawned a bullet. Therefore, real quick bullion we'll call it called on Well said it toe falls by the port Over here I took If we are holding the space pardon, we'll start the Kulti. But before that we're talking. If we have not called, which means, if called is set to falls, we are starting the Corton and even here will took if called here be attacking if Carly set to True. We are spawning the bullet again over here whenever we call the according we'll set call toe True because we're calling the cording on we'll check whenever we released a space body by typing input Dr Get keyed down the key code dot space Well said called to fall. So what? Just us get key down returns true whenever we released our button. So whenever we're releasing the spill button, we're setting called toe False because we are not spawning the bullet over here called the center Falls. Therefore, it will not start this corden on it will not spawned the bullet And again be a pressing the space body that's called a set of false were sitting in tow through on We are supporting the bullet again. Cool. But over here we should Chuck, whenever we are releasing the space body, therefore will say yet he up this it comes true whenever we have released the space. But I'll set time between phone 2.3 because I need to spawn bullets every 0.3 seconds. No, If I hold space, bullets are being spawned every 0.3 second. If I released the space button, no bullets are being spawned. But if we turn to the left on if we try to shoot, bullets are trying to move this side because we're only rotating the clear and no d bullet whenever responded bullet. The tradition is set to 00 and zero because the bullet points rotation is set to 00 and zero. Whenever we put the player, there s a free donuts duels left. We need to move the bullet in this direction. They reflect a tree dot left. So therefore, let's go to play a script. And whenever we are changing the player rotation, we'll also change the bullet points rotation. Therefore will say with that position, Dr Angles equals new active three zero comma 1 80 commas. You corporate Aseem. I'm a basic over here. Well said its relation to 00 on zero. So whenever we are changing the rotation of the player were even changing the rotation off the bullet point. If a tradition is set to zero 1 80 on zero, the Bullets, which are being spawned, our which will be spawn even its rotation will be set to 01 80 on zero. Because whenever we responding the bullet we're sitting the bullets rotation to build positioned our tradition. Now we have changed the rotation off the bullet point on. Whenever this bullet that respond, even exhortation will be changed in the fixed up late method Will Chuck. If transform dot you're angles dot y is equal to feel will avoid. The world's right effort is equal to 1 80 Real Mort. You will still upside release whenever, whenever bullets, while rotation distinct is zero. We are mulling it. The world's right. Whenever I had said to 1 80 which means the player has turned the world's left, we're moving. Label it, the words left Now if we hit play now, we trying to spawn the bullets. The bullets are being spawned in the right direction when returned to us left and part of black. The blacks are moving towards the left, but you'll see that the bullets are falling down that is because we have not said the gravity scale to zero. And you even noticed that the players fire animation is not getting played. Let us head back to the code. Will you go to a play script whenever we hold the space button? Well, say anim darkly. The fire animation, which is distinct fire. And now the bullets are being spawned on the fire animation. They're splitting. But whenever we released Space button, it is not going back. Toe Island mission. And even when we walk and fire, the animation doesn't look right. But first, whenever defy our animation has been finished, will transition back to the island nation and in the script Well, Chuck, Yes and good. Don't get axis war tickle. It's not equal to zero on and could not get access. Horizontal is not equal to zero. Andi input. Don't get key. Oh, well, suck on. Call it because whenever we are holding the space button called a set of truth, this means whenever we are pressing the arrow keys are the W. A s and Dickie Andi. If Calder said true, which means if we are holding the space button, we will played the walk on for our animation, which is this thing mix so that this name matters with this name with this over here. If it's not matting, the animation will not get laid on. Then whenever this admission has been finished, we need to transition back to the island. Nation will play the fire animation on Let's we are not Morning the player. It just means if the horizontal and vertical axis are said to zero Well, here we are playing the walk animation Venable. We are presently horizontal or vertical Pardon. So the peace. But we only need to play the walk animation whenever we are not personally space. Pardon. That is, whenever we are holding the space pardon and we are not doing the character, we'll play the fire animation and we know where we are moving the player on. We are all in the space, but we are playing work and fire animation over here whenever we are moving a player. Andi, if not called, which means whenever we are holding the hors d key on, if we have not pressed the space body, so whenever we have not Christie Space Button called it said to falls. Therefore, if we are not holding the space button on. If we are trying to move the character or the player were playing the work animation. Over here we are talking. If input vertical is not equal to zero on Dhere, we are using the and operator. But we need to use the our operator because when there will be a pressing the vertical button are whenever we are pressing the horizontal button. Andi, if we're holding the space button, we are playing the walking fire animation relied excessively brackets over here because we took this condition past. And then we'll mourn toe this condition we want here before playing the work animation. We need to talk, if not called, which means, Corley said, toe calls on. That means we are not holding the space body and even will include us accepted off brackets over here because we need to tell this condition past, then we'll move into this condition. Now if we say this and head back to India innately, everything works fine. You see, whenever we are going to character and holding the space body, you walk and for your animation gets please on whenever we hold the space. Parton on. We're not doing the character. Only the fire animation is getting played. But the bullets are not being destroyed during this scene. Therefore, we need to destroy the bullet. Right? Do you go to the black script? Andi will destroyed bullet when it was spawned. Let's try this game or checked after three seconds. So we go to prove perhaps bullet on will increase the speed off the Balet. It's a little seven. No, we spawned the bullets. The bullets will get destroyed after three seconds. You see, It is getting distrust. But play can me out off the camera. Are this scene right? So let's fix this. Now. We'll go back to the clear script turned over here. We need to climb this position. Therefore over here. Well, same opposition. Equus be that position. Bless opposition. So we have copy pasted the same thing which is over here on here will say blue position because new position. Place Abby. That position it's over here on its value is set to more position itself. So we need to clamp the values off the opposition. Therefore will same opposition dot exe equals Mattis. That plan more position. Doctor X between so I don't know. I don't talk it out. We need to play you. Toby within 6.54 on minus 6.76 in the X axis. Therefore will say 6.7 on six point. We'll do the same for the Y axis instead of sex when seeing wife, and we need to climb the position of the player between 4.5 on minus four going to in the y axis. So what this does We're not allowing the player exceed this values, which means we are clamping the exposition off the player matter. The clam is a function which takes three arguments. The 1st 1 is the value that we want to clamp the 2nd 1 esteem, minimum value. And it told his team, Max value. We're clamping this value between this value on this value were not allowing the player to exceed exits, explained eight. By because he goes off screen, we don't want the X value Toby less than minus 6.5, the same with the Y value. Now, if we hit play on, if we try to move the player, the player cannot go off string because its Y position is 4.5. As it is, the max value is not allowing the Y position to exceed four point fight. The same for the negative value. White on. Be swell. See, I'll increase to play a speed to five. So I link used to play speech. Fight. I'll take apply because I need toe. Make these changes in the prefab. Whenever we dragged a prefab, it will have the same settings as this thing. If we did not click, apply whenever we make changes over here, the changes we made will not be set to the original prefect. Now we have set of the player. Let's clicks. Do you see Andi? If you have any doubts related toe this tutorial, you can ask me in the discord server. Thanks for what industry you 4. Setting up Spawn Manager: Hey, game, develop ALS. The Sankyo from sang sobs. In this video, we'll set up the spawn manager, but before that, let us create a new folder, will call it Script on, then will drag and drop the scripts inside the sweeps. Fallen in the scene or in the hierarchy will create a empty game object. Really call It spawned. Manager on. We'll reset the position up. It will add a new stripped for it. We'll call it spawned manager itself. Now let us create the points where we need to spawn the zombies. Let's create an empty game object. Reset its coalition. We'll call it points. Will could empty game object will drag it over here. Here you can see the small drop down on select the icon told at this empty game object is visible in the thing. Will rename this to one on Drag it over here will duplicate it by pressing control D on. We moved over here, the select boat off them. Will I be impressed? Controlled. The Andi will drag it over here. Let's quit on empty game object. We'll call it left on will drag all these points inside the lift game object I mean in this points. So now when you click on this left game object, its position is here. But its position must be over here, right? Because now, if we try to rotate this points, rotate about dis points. Now, if we remove the child's from this object on, If we drag it over here on, then if we add this game, object to that object. Now, if we try to rotate it, it rotates currently. Now, Lex, duplicate this whole game. Object brings you name it to write on will drive it over here duplicated again. Well, rotate it to 90 on the Z on driving doing here now we can create extra set off points right over here on over here. I limit to file on this to six. I really, in this toe up are a duplicate it on. Drive it to the body. I really am this to down? Yes. Now we have created the spawn points. Now it's time to code and spawned his own base. Therefore, let us open spawned manager in order to spawn zombies or the objects. First, we need the reference for these porn points which we have created just a second before transform as there are many spawned. Points will make this us are a we'll call it spawned points. I'll create a public end Children number off some bees to spawn. Yes, this will be the total number of zombies that we need to spawn in that particular level. And then, with the public float, we'll call it time between spot. I actually will say it. Max Time between Spawn will cooperate based it again on We'll call this as meantime between sport and say why we have created this two variables later, over here, we create matter. We'll call it Spawn before spawning. We even need a reference for the objects that we need to spawn. Therefore will say public game object. I need to spawn to Thomas. Well, corrida Ari on. We'll call it zombies in this born matter, respond is on me in a random spawn points. Therefore, to spawn objects we need to use instant. She ate function well. For instance, Sheet. The first argument is the object that we need to spawn. I need to spawn random zombie out off these zombies. Cilluffo. I'll say zombies off random dark greens between zero on some based darling. So what does this random doctoring? Here is a function which it does a random number between the first argument on the second argument as arraigned extracts from zero I have passed the first argument at zero on I'm passing the second argument as the zombies Lind consider that are two zombies. Okay, this function will return random number between zero on zombies. Dorland, which is to it will deter neither one are zero. It will not return to a second argument. Is the position where we need to spawn the object? Even here, I need to spawn in the game. Object in a random point. The forces born points offs, random doctrines between zero on spawned points, darling. On the third argument is the rotation. I'll say that squadron in dot identity, quite onion dot Identity is just 00 and zero. That is, whenever we spawned the zombie in a particular point. Consider this as a point. It responders on being this point on. It will set its rotation 200 and zero because Qahtani in North Island, Eddie itself means the object will have no rotation. This line off course spawns a random zombie at a random point with no rotation. Now we are not calling these scones function in order to spawn became upset. Before you start, we'll call lease born function. You said this and head back to unit. But before that over here, we need to pass the position of the game object. But we are passing the transform. Therefore we'll see dork position, which is nothing. What transform that position? I will say this and head back to unity. Let's click on this bond manager on. We'll click on this more love wooden, because if we go back to the hierarchy on select different objects, we can't see its information in the inspector because we have locked the information off this object novel in last points will select all of this points on you drag it inside the even the right up and down spawn points Cool. My real unlock its I said the total number off so miss to be spawned. As for I'll go to pre Fabs Island Tower decides us, too, because we have the males on me and females on me Now for hit play one. Somebody must be spawned at some random point and so it has been spawned. Now if I played again, the zombie will be spawn at different points. So it's solar here. Awesome. This line off course ponds, random zombies at random position. Now we need to spawn the zombies. Do the spawn rate over here will get a courting we call it. I am numerator on one. See spawned zombies inside this That's a yield written new. Wait for seconds on over here with the random dot Rene's between meantime, between spawn on max time between spot. After this, we'll call this pond function. Then we'll study Cortina D instead of spawning. The zombies will call this quoting whenever we start the game. This Gordon is called, You know, Richard, new bait for seconds. We'll wait for some time and execute this code. Here we have toe enter the time until what we want to wait. I have so dragon dot dreams men Time between spawn and Max. Time between spawn. We'll be assigning the values for this over here, as I have made it as public And, yes, random doctor insurgents. A random number between the meantime and Maxtor. Consider the meantime as Ford on Max domestics every time when this Gordon is called a random number between four and six. This generated consider, just fight. It will wait for five seconds. Then it will call this spawn mattered. Therefore, Zombie will respond at some random place on I'm calling recording again it and does it again. And now let the random number be full. It will wait for four seconds on. Then it will call this born method. It responds, albeit some random place. And then this golden is called again. When said this and it back to unity, I'll enter the maximum between spawn. As for in the meantime, as to now hit play, zombies will be spawned at some random places after 23 seconds now is only spawned over here none of the one the other one. And yes, every two or three seconds Zumbi is being spot here. We had greater are variable called total number of some means to be spawned. That is a total number of zombies. Will it respond in that particular level in this part? Mentor, after spawning a zombie well, dick lament the value off total number of zombies to spawn before calling the courting on this born function well took if total number of zombies to spawn is greater than zero. If yes, well spawned a zombie on, we'll call the court in again what this means considered the total number of the Mr Spawn. As to first, this court in is called two is greater than zero, right? So what we call this function? It responded on me on the number of zombies. Is Dick lamented by one. Tu minus one is one again this code and it's called It will wait for some time. Alittle took If Oneness Little Dan zero. Yes, then it respond The object. It will recommend this value by one. Now it becomes zero. Then this court, and it's called again. It was very for some time. It will talk if zeros due to Dan zero. It's false. Therefore, it will not execute this code, and it was stops wanting the zombies simple. Let's stop this out. I'll enter the door. Lumber also missed to spawn. As to now, only two zombies must be spawned, so let's wait till it gets born. One to and yes, even after two or three seconds, Those on bases being spawned because we have spawned ing to zombies on Day four. Total number of zombies is set to zero. Now we need to use some me to move towards the player, and at that came right therefore will flick on the zombies prefab, the select. Both of those on these will add a new script on We'll call it and some be Let's open it up here. We need to move. The summit was the player. Therefore, first we need a reference for the player object. Let's say gin object will call it player The start function. We'll see player equals game object, not find game. Object with tag. I will pass, please. So what this does whenever doesn't be east spawned, it will find a game object which bag called player? Let's tag player as player. Why tax are used right now? If I could play, the zombies will be spawned. The prefab name is male. Some B and females will be, but whenever it is born, its name is changed. An extra clueless added to it right. So instead of comparing the names, attacks are really useful. Tax are just like names and it won't change. We have doubted US player on this function. We'll find the game object, which has a tag called player. Whenever doesn't be spawned, it will find game object with house attack. All player here, no object has attacked called player except the player every game. Object Ystad as untapped Except it can dry stag. That's mean camera on. The players start. Best player. Anyone doesn't be spawned. The player game upset will be assigned to the player in the update function was transformed that position. Equus victor to dot motor words move towards takes three arguments. The 1st 1 is the current position off the object, therefore also transform that position. The second argument is the target or the object towards which we need. Toe. Move this game Object as I need to move this object was the player I said clear. Don't transform that position. The toad argument is the max distance, all the speed. Therefore all trade available. I'll call it Speed on here at fast speed this line off court. Just most This game object, the worse the player with the speed. Now, if we said this and head back to unity before hitting the play button, we have to set the speed off zombie. I'll set speed off demands on me as to on the females on me as one. Now whenever we hit play, the Giambi's will respond and it will move over. Supreme see, as only has been scored on it has been moved towards the player simple. But over here we have to multiply the speed with time doored all the time. Because we want this game object to move with seems speed on different devices. On the current reason is different devices have different friend lit. So therefore we need to move this object for a second and not both free. Now it's the heat play as we had multiplied with time Gardel time, it will move slow. So did the army has been spawned that it this morning toe will simply simple. But whenever it is towards the player here is not attack Animation was not being plead right. We'll click on the firstly Conte females on me We'll goto animator And whenever we spawned the zombie we need to play the walk animation and not the attack right. Therefore will said this ask default layer and whenever we played the attack enemy, so we need to go back Julie Walk animation or whenever the attack animation has been finished, we need to go back to the work animation. We'll do the same for the males on me. No, Whenever doesn't be being spawned, what animation will be pleased. But when it is too worse, the player or when it is nearer the player, we need to play the attack animation in order to play the animation. First, we need the reference for the animator. We'll call it on and the stockman dirt when, say, an M equals get component. The animator at that's toe this game object. Over here, I'll create a public float. I'll call it Men. Distance on In the update I took if in vector toe dark distance between the current position on the player position, it's less than Min distance. We'll play the attack Animation, therefore built the enemy Sendak play a duck have diabetes US Attack because the animation named that I Need to play is attack itself. This function returns to the distance, but being the first object on the second object we're talking in the distance is less than Min distance. We're playing the attack animation suppose and I will head back to Unity will enter the min distance as one 0.2. Now, if we chuck this out whenever there's some weeks near the player attack, animation will be played on whenever it's not walk animation with me, please. Zombie has been spawned. It's moving towards the player, and now you notice attack animation is playing on whenever it's not near the player work animation s plane. But if the player is towards the left, the zombies are not turning towards the left right in this case when it freaked the zombie because we don't have any child objects. And even if there are child optics, we don't want it to change its position. When we need to flip this game object. Let the explanation off the player B zero and explosion off the zombie. Me, too, if we subtract the explosion off the zombie with the player it is to minus zero isn't less to. If it is negative one, we need to flip the zombie on. If the position off the zombie is minus two on the place, worsen is zero minus two minus zero is minus two. If it's negative, we should not flip this on me because it's what faced the player. We'll go back to the some be script. We'll talk if transform dark position dot exe minus player door transformed our position dot Exe. He's a great dan zero. That means it's positive before flipping. First, we need the reference for these private Render. Therefore will say Sprite render. Render will call it Sprite. I need to start function Well says Right equals get component. Sprite render. So whenever we play the game, this is spry. Gender is aligned to the Sprite variable over here if transformed. A poison dart X minus player that transformed the partisan vortex is greater than zero, which means the value is positive. Onda Zombie. He stores the right off the player. Therefore, we need toes. Flip the zombie. There's this bright dot flip X equals stroke. We're just enabling the flip X whenever the zombies to us, the right off the player real copy the same based it again. Over here will talk if it is less than zero, which means the value is negative. Will set flip X two falls. That means we are disabling the slip X. So now this must work. Let's stop this out on rest. Summing okay has been spawned. Now it has flipped. If I go to us, right, It slipped towards the right. Andi, if I moved was the left. It flips towards the left. Super as you saw, the player can push the zombies ended on the script. I need to design a random speed between the men. Speed Andi Mack speed and sit off speed will say random that range between the men. Speed on the max Speed agents. Ah, number between the men. Speed on a max speed I take on the isle Selected zombies. I will say men speed as country. I'll set the max speed asked one. Now a random speed must be assigned to the zombies. So yeah, it has different speed. But whenever they attack we need to reduce players help. But first will create a cider for players. Help will go you I willfully gone, Slater. We'll drag it to the top. Now you see that this lighter is below the image Is all this price Therefore first will trader you I canvas We said its order in layer greater than distinct. So it's orderly. Zero been said it's ordered earlier to one. Now if we greatest lighter, it will be on top off the stripes as we need to scale the slider according to the screen size will select scale with screen size. I'll drag this abo we're here. I reset the background image the Philly area on. I'll delete the handle, I said the fill color too. Something like agree under select the background color as grace. More race now is he opened the place script. We'll create a variable. We'll call it help Next We need the reference for this later As we are using the you I we need to import a class called unity engine Darty eye here will save public slider will call it Listen And the update matter S l that value equals hope. If you click on the slider, you see that Be mean. Value said 20 on the max value said to one. But we need the max value said to the health. They finally start my third You say sl got max value equals health and initially we want to set the value off this lighter. So the health that is the health must be full. Therefore, in start matter will say a sold out value equals help. So both now we click on the player and then we'll drag this lettering. Well, said the health. Too 100. Now let's replay as you see the sleight of value, he said. 200. And even the max value is said 200. Now, if I try to decrease the health, even the slider value changes you started. You won't hear the slider value changes sipo That's it in this video, if you have any doubts regarding to this tutorial Yes, you can join the discourse over on. Ask me there. Thanks. For what? In this video. 5. Wave Indicator: Hey, game DailyKos So Sankyo from sand Sets and this video will be creating Web indicator for our game. But before that will rightly consular will create a text will be name new text to help on the drag it over here, I'll increase different size. I would rename this slider toe help slider duplicate it on a little more. Over here. This will be the very indicator will enter the text us we've I'll choose the color as white . Now we will open this born manager first. We need the reference for these lighter But before that as well. Be using slider. We should import unity engine, don't you? I class. And now you say public's lighter. We'll call it we've on in the start function will save you Don't, Max. Value equals total number off zombies to spawn in the update metal, I will say, Hey, Doc value equal stole number off zombies to sport here. We're setting the max value as total number off zombies to spawn. And here we are setting the slighter value to total number of the beast to spawn. Now I'll drag and drop the wave indicator. Andi, we should only spawn zombies if game object dot fine game object with bag player is not equal to know which means player is in the scene. I said total number of zombies to spawn as 20 and now we have the wave indicator. You saw that the slider value has reduced. So whenever we have spawned all the zombies we need to enable the win panel, therefore will duplicate, this will call it as one we create a new text retractable on. Then I said, It's color to white will rename this to one you under fixed on increased the foreign size Instead of retry, I'll type next level. I'll disable this on in the diet battle. I'll create a new text. I'll call it enough. I would drive it over here, I said. It's got little white on the phone size to 20. I'll even disable this. So whenever we have spawned all the zombies, we have to enable the one panel. But before that, first we need the access for the one panel. Before was the public game object. One panel in the update method. We'll check if total number on somebody's to spawn it's less of dental equal to zero will enable the one panel and even we have to check whether Blair is alive in the scene. Therefore, will say game objects. That fine game object with tag player is not equal to know on. Even we have to check whether there are no zombies in the scene. Therefore, it's a game object dot fine game object with tag. We'll call it somebody, as there will be many game object. Oh, there will be many zombies eventually find game objects with attack. This function returns. All the optics with has been tacked as zombie. Therefore, it will be on our A. Well, Chuck, if it's lent, is equal to zero. That means there are no zombies in the sea will enable the one panel you say this. I'll drive the one partner, and there is a total number of zombies to spawn as one they go to pre fabs on for the male and female zombie will add a tag. Call Zombie now for you to play whenever I killed the last zombie. One panel will be displayed. Super. Now, when we click on the buttons, nothing happens. Therefore, let's create a level order. Well, our A script. Call it level law order on, we'll open it up. First, we need a reference for the loading screen. Therefore, with the public game object, we'll call it. Loading screen will create a public void. Call it Lord 11 on here will take a string as argument, which will be the level name he will say application dot lower level the level there we are loading the application that lower level just loads a level. Protests any past the first argument. Now recreate our new panel, which will be a loading fan. We'll call it loading panel. I reserved the image on a lot of text. I rename this to Lori. I'll change its form size to 30 and said its color to black. I'll increase its size. I'll said the loading panel color to agree. I disabled this planet because when it will be load again, we should not see the loading family. We'll click on the bottles, rely there level loader script, and whenever we kicked the button, we will call the Lord level function so all the buttons will add the loading panel. So whenever we click retry, we need to load this particular scene as this particular scene name is Game Al Qaeda game. So whenever we click the main menu this button, we'll call the lower level function from the level loader script. Real Call the men who've seen which will be creating later. We'll do the same for this main menu. I'll rename this to next level Over here. We never would click this button here. You can enter the next level me as I only one scene I'll their game itself. Set the scene. It's better if you said time that time scale back to one whenever the player presses. The main menu are very dry button because if you have something going on the main menu, all the level selects and many on when a player presses two main menu main menu level will be loaded. But the object will not be moving as we accept time scale to see you. Therefore, it pause the game in order to resume it. We have to set it back to one therefore whenever the player rsst main menu. But make sure you have said time scale back to one. That's it in this video, if you have any questions related to this tutorial, you can ask me in the discards over 6. Reducing Player's and Zombie's health: Hey, game developers. So some kale from San sets in this video will reduce players health when it was Ownby's collide with it and even whenever we shoot at zombies well, there you zombies health well, more into the zombie script. Our hair will create a public float. I'll call it damage on, Then calculate a public slowed I'll call his health. Here. I'll see hiding Inspector. Anyone here because I don't want to assign value for these two variables in the Inspector. It will hide this variable from the inspector. That means we can't see the value. Are assigned value in the inspector into stock. Mature. I'll set their random health to the zombie. Therefore else a random that range. I was like a random help between to coin. Who? Andi Cyberdyne. Three. On the one. I'll set a random damage. They will say random dot range. I said the damage between five on day 10 of maybe yes. So whenever zombie collide with the bullet, I need to reduce the health. Therefore, right over here, I'll see White on collision. Anto, I say coalition. I call it bullet Are no B. J. Maybe it can be anything. It's destiny on collision Enter is a function which detects collision. The things inside this function will be executed whenever the object collides with something. But to detect collision you need to type collision and variable name over here I'll took if oh, bt dog game object Dark tag equals equals bullet. Either use health by one. I'm using the tag because minimal ability spawned its name will be changed to Bullet clone . Now I need to assign attack for the bullet. Right. Therefore I'll click on the tag then this new attack Cold bullet they for public on at tag I learned a new tag. I'll call it Bullet on now to the bullet Repap I assign attack called Bullet Super I think on player Albert Giusti time. It means Spawn 2.5 as this is a two diamond silky we know to add story over here. You in here now? If we said this, hand it back to unity on whenever we tried to suit and some bees took damage, message must be displayed Esten. Somebody has been spawned. I suited him. And yes, you can see a message called took damage. But the bullet is not being destroyed on the bullet is pushing the zombies. Even the player will cost the zombies. Therefore, we'll set the body Type two kind Matic on even the zombies body type to kind Matic. Make sure that you have said the bullets body type two dynamic because we want a bullet to collaborate enemies or the zombies. Whenever we collide with the bullet, we need to destroy it. Therefore, we'll say destroy as we need to destroy people, it will say, Oh, bt dot game objects with a modest message. Yes, this works fine, but whenever the zombies collide with the player player, hurt is not reduced. Will drag borders on base into the scene? We'll go to a window animation on over here and select the attack animation whenever we play the attack Animation man, whenever it has been finished, will invoke a function here. I will say fast Public Wide Damage Player. I have said it s public because I will be calling this function whenever attack animation has finished playing. So after playing the attack animation, I click on the small button with this argument on, you can see a small square over here. Click on it on well, said the function to damage clear. So whenever the attack animation has been played, we'll call the damage player function. So now we need to damage D Player or being it reduced to help off the player, right? Therefore, we need to get this health valuable over here. We have already access to be player game object by using this line, of course. Therefore, I'll say players don't get component. Really. A script dot health minus equals damage. So in the play a prefab, which is this thing? We are getting the player script. You're saying get component the clear script this thing on. We're accessing the health variable from the place script on. Then we are really using the value of health by the damage. Superb. Now, if we go back to unity, let's even make the change with the main somebody. After finishing the attack, animation will other. Even we'll call the damage player function, will flick on the sand click apply because we want toe, say the changes that we have made in the prefab. Now, whenever the beams collide with player on, whenever attack animation has been finished, playing clear health will be reduced so go to canvass or the player as we are reducing it by a small amount, you can see that the player help will get traduced. You saw that it's a boat, but whenever we try to shoot, the bullets passed through the zombies because it's our in layer it. Secretary on the Zombie started earlier and said to to Therefore the bullet will pass a both families on this leftovers that order in later to to make sure that you have said the bullets body type two dynamic because we want a bullet to collaborate enemies or the zombies in the update mental in the zombie script with Chuck it, there's some beheld. It's less the dental record to zero. We'll destroy. These are the four will destroy game object. So now, whenever we should at some bees, their health will get reduced, and if zero they will get destroyed. And yes, they are getting destroyed. But whenever zombies are near the player level past, they will move to the player position. Therefore, we don't need it. We need to stop the zombies walking. Whenever this distance is less done, them in distance. We'll head back to the zombie script before moving it to us. A player. We'll talk if the distance between the player Onda Zombie is created and, um in distance, we will more towards. Simply now we head back to unity and hit play. The zombies now will stop at certain point. But whenever the zombies collide with a player on when they attacked, the player the player held will not reduce at the same time. When we move apart, then it's play. Health gets reduced. This is because the attack animation is called so many times on. It is not finishing the attack animation because we are talking. If it is less than the men distance, we're playing the attack animation. So here we have to play the attack animation if we have finished playing the animation, which is nothing. But if we have stopped playing the attack animation, consider this distance is less than ministers. We have called the attack animation on as it is in a plate method, I will come again. It took whether this distance is less than in distance, and yes, it is true. Then it will play this animation, but we're not waiting till the attack animation has finished playing. So as a result, we were calling this function at the end off the attack animation. If that that can emission has not finished, Please on If it's starting from first again, we're not damaging or we are not using the helicopter player. Therefore, build Re will play the attack animation. If no animation are the attack. Animation is not playing, therefore will say if not hannon dot get current animator State in Full. The Layer Indexes Ciro dot Easy name I would say Attack. So what distance? If not the current animation that we are playing has the name called Attack were playing the Attack and Mission? That is, if we're playing the walk animation, this will return true on. We'll play the attack animation. Now if we say this and head back to unity, My work animation is being played whenever the zombies near the player. So yeah, attack animation gets played on. After finishing it, Walk animation will be played, therefore, this condition will be true on. Then again, we're playing the attack animation. Therefore, the damage matter gets called every time after finishing the attack an emission and as a result, player reduces after finishing the attack animation. But if the player healthy zero we need to destroy the player on enable the DI panel or the diet final First, we need the reference for the dye panel they foiled. Say publicly. No object di plan in the update. Metal. We'll check if health this lesson. Dederick with zero. Then we will destroy this team. Object on Then we will enable The Dye panel, therefore will say that panel dot said acting through this just enables this panel Now let's create a die. Pamela, will you call this canvas? Well, writing on it you I on a family lucid The image they call it US Die plan. I'll create a button. You are a button. I reset the image. I said It's color too gray on I said, the background color for black. I'll rename this to reach. I duplicated. I'll rename the Strom a Neman Drag it up. I live in renamed the text to retry on mean you. I'll change the text color to white. Well, I'll increase the foreign size. Drag it to everybody. Every time we play this game, the panel will not be active. So therefore, whenever the player healthiest less dancy rule. We are destroying the player on. We're setting the dye plan to true. That is, we're enabling the dye panel in this way. Let's society died. I know whenever the player dice or whenever to play healthy Last sedan zero That panel will be. And yes, the panel has been enabled. Andi, the player has died, but zombies are alive on you can see air call missing reference exception and a zombie script. If you go to these on the script here we are looking for the player on here. We are moving zombie towards the player, right? If player dies, there will be no player on place. Value is set to know In order to fix this well, even destroyed the zombie. Well, Chuck, if clear is equal to know with me, it's player has died. You will even destroyed this zombie. I'll start the players help us. 10 Player is not equal to know, which just means if they is not in the scene, we will not perform these tasks. If the player is equal to know we'll save time. The time scale is equal to zero line, of course, is just used to pass the game. So now after place that there is no error. Cool. That said the scene. That's it in this video, if you have any doubts regarding to this tutorial, you can asking in this card server. 7. Spawning collectables and randomizing zombie's scale: Hey, game developers So Shankill from San sites. And this video will spawn collectibles whenever zombies has Bean died. Therefore, will drag and drop The Iranian well said It's orderly your to to because we want it on top off the background will rename this to help A polygon collided I learned a rigid body. I also did sporty type to kind Matic. Actually, you should said this to Dynamic. If you said this s kind Matic player will not able to collide with it on Galati just to show you have said it s kind Matic and even gravity scale He said 20 Whenever you choose Kind Matic, I said collision detection to continuous on a free Steve position as the last tradition. Let's out a tag. We'll call it help and we are health back. Put on drag this object inside pre fabs. I reuse it size 2.1 0.1 and point as like apply to make effect on the pre fact I'll deal with this. Now let's click on the zombie Pre fact. The zombie script over here will create a bullion we'll call it sponsors. Collectible initially will send it to falls in the start function well took. If random, dark value, it's less than 0.5. Who said Sports collectible too true. So initially we are setting spawned collectibles to falls random got value. Britain's value between zero and one. We are talking. If the random value is less than 0.5 left, we're setting spawned collectibles equals True. That means this zombie will spawn collectible in the app. Need metal Before destroying this object, we responded collectible. But first we need the reference for the collectible. Therefore, let us see public game object. If there are more collectibles, you can say this. Ask Ari. I'll call it collectibles on in the update. Mentor I'll Chuck. If spawns collectibles, I'll in Stanciute a random collectible. Therefore, collectibles off random dot range between zero on collectibles. Dorland. So then I need to pass the position where I need to spawn this subject. I'll pass the transform that position. It is the position off the zombie and then as a quite in unit identity for the rotation, because I need to set the rotation off this bond. Collectible 200 and zero Super Now zombie respond collectibles in the player stripped whenever we collide with the collectibles, we have to make some effect for therefore, in order to detect. Collision will create a collision method, therefore, will sit on collision, enter collision or Bt just if the collided object has a bag called health, then I'll increase the health value off the player by 10 on. Then I need to destroy that collectible. The world's they destroy game object, their strike or beauty. Don't game opted? I'll destroy after implementing the health value by 10. Ask. This is a to begin when you to say to me, you one whole here, Anya's on. Now some zombies will be able to spawn collectibles, and some will not spawn collectibles. I'll try to kill their zombie so it's coming over here. But you see that I can pick up this collectible, and even if I shoot on it, the bullets are stuck on. Instead of writing this method, here are a new script for the health. I'll call it Health Increases on the health game. Object on no no collider enable East trigger because we only want to reject collisions on not actually collide with objects like somebody's. If you have not mark this as East Trigger zombies may stop walking when they collide with it, I'll open it up and this script, I'll add the collision function as I had must discuss peace trigger instead of one collision. Had to say on trigger enter too. Instead of collision, we have to say collider on here. This script doesn't have health variable. We need to access the health from the player. Therefore we'll see came object dot find game object with that called clear on after finding the player we need to get the place stripped. Therefore, if they get component clear and then we're decree menting the health value by 10. Instead of destroying the collided object, I will destroy this collectible here instead of health. We know to check whether the colored object ex player on Mr Finding the player we can just say Oh BT as the colored object has a tackled player he displayed on before we can access deeply a script from the player object. Make sure to have said the health body type two dynamic because we want it to collaborate. Player, I said they helped 200. Now if I tried to shoot any off the zombie. Some zombies must born collectibles and some should not. First time state damage. Okay, so now I shoot him. It has spawned a collectible. So now I can pick it up. As you saw health value increased Cool. I said the player help to zero. And now I deeply Whenever the player dies, this panel will be displayed on we have indicator is about the Spanish therefore will drag die panel below the wave indicator now being able this, there will be no way Vindicator Whenever player has been died, we're setting time. Skin 20 which means we are pausing begins before your time. The time scale equals oneness. This just resumes the game. So whenever we start the game yes. Setting time scale to one. It's better if you move this to the player script. The state is handed back community I say the scene. I just enable the giant battle For now, I said clear helps to one. I know whenever player dies on whenever we click Retry button timescale iss sit back to one On day four we can play the game if you want a random scale assigning toe the zombies open the zombie script on as we need to change the values off the scale. First, we need to access to transform on, then the skin. They fall in the stock matter. It's a transform to access the scale value, if you should say local skin, not just skin. As local skill has three values, there is the X Y Z. There is a new rector tree on. Then we left on a random skill for the zombie. If we want to us either random skill, the X Y and Z values must be seen to look perfect. Now, if I change the skill value 2.4, it looks good if the X y and Z value you seen. So therefore, if I see random doctrines, so I'll scare the zombie between 0.15 f on 0.4, as we have like three values for wrecked, a tree will place this another two times. Make sure you have either the calmer this random governance function, returns and random value every time. So as we have corporate this two times, this will return around on value 3.3. This will little random value, say 0.17 on this will return a random value se 0.2. Therefore, the values are not saying so. Let's create a variable. We'll call it size off load data Type on hell is this Size equals random dot range between point by point for here. Instead of calling the random doctrine function. Will pass size Ask the three values So no, the X y and Z will have seen values. Let's head back to unity Algernon Zombie. So every zombie must have a different skin. Next, wait for the zombie despond. And, yes, let me this somebody has 0.276 as all the three values. This is MBS 0.39 on this somebody asked 0.33 So every somebody will have different skin. Super. If you have any doubts they got introduced. Tutorial. I think you know what to do. Thanks for watching 8. Spawning particle system and a boss at the end of a wave: Hey, game developers. So Shankill from sand starts in this video will be spawning particle systems. Whenever bullets collide with something, anyone will be spawning a bus at the end off the day. First, let's create a particle system by going to FX body Go system as we want this to be on top off the background and everything else will go to render well said It's are related to four . So now it will be on top off the background. Andi believe zombies. Now we'll go to shape selected shape to circle research. Extradition to zero on will reduce the jurists in 2.1. Even the lifetime will tell its lifetime 2.15 Well said its speed to one size 2.3. We'll goto emission separate over time to 50. So now we have the school effort will decrease its radius 2.5. Even the thickness will send its color toe black. I will even increase the writ. So I think this is an earth we 100 well and took looping because we don't want to look the particle system. So now we have the school were drag it into the pre facts on will open the bullet script so vanilla we collide with something we need to spawn the particle system. Therefore, first we need the reference for the particle system Will say public game object particle system on Whenever we collide, we need to spawned a particle system. Therefore, to read a collision we need to write wide on collision Enter jury inside this collusion to on the reliability. So now the bullet has collided with something. Therefore will instantly it the particle system. It's a particle system on well spawn at the village position with nor occasion. I'm passing the position where I need to spawn has transformed our position because whenever the bullet collide with something I need to explain at this particular position. Therefore I have said transform dark position. I'll click on the bullet on I'll drag the particle system now whenever i it the zombies particle system must be spot. Okay, so you saw that cool effect. You can also play with the settings and make it look even cooler. I'll delete the particle system from the scene. But whenever we instantly the particle system, it is not being destroyed. It will be simply in our scene So yes, it has been spawned, but it has not destroyed. Therefore, we'll add a script to it called We call it Destroy. All on will destroy the particle system. After one second, we don't need the update matter in the start. Mental, you said Destroy this particular game object after one second. So now this particle system will be destroyed after one second after it has spawned will move the script into the strips folder. So I now will spawn boss at the end off the veal. Therefore, let's open this pond manager first. We need the reference for the boss. Therefore bills of public game object. We call it boss on. We need to spawn this boss at the end of the village. Therefore over here will say else on. Then we'll spawned the boss instead of zombies. I'll say boss on, That's it. Imagine total number of zombies to spawn is set to 00 is not better than zero. Therefore, it will enter the else condition. And here we are, spawning the boss at some random point in the spawn points with no rotation. Now I'll hit save as I have no boss, I'll just drag and drop the fat boy bomb, so I'll make it a prefab. Then I'll grab this into the boss game. Object as that, the number of the beast to spawn us, too. So now, after responding to zombies, the boss must be spawned at some random point. Let's talk whether it works or not. Find one zombie, the 2nd 1 And yes, the boss has been spawned. Make sure you have that The bomb seem as a zombie are as the same time which you had packed for the enemies. Because here we are talking. If total number off zombies is less than or equal to zero on a, the player has not died on. We're talking of zombies in the scene is not equal to zero. And then we had explained the one panel. If you have not that the boss as enemy are the same tag as you haven't notable here after destroying all the zombies. Now the boss has no tag. Let's say it has a tackle untapped. Therefore, the scene has no game object cards on me, and it will display the one panel before destroying the boss. If you want to spawn the bus after destroying all these Somebody's just remove this line off court on more toe the update matter in the update my third built If total number of zombies to spawn aims equal to zero on over here, well say total number of the beast to spawn is equal to minus one. So whenever told, a number of the mistress one is equal to zero responded zombie Well said the number of enemies to spawn to minus one. Cool. Andi, even we need to talk whether the player is alive on There are no zombies in the scene. Therefore will copy the same court which was here and based it over here. Yeah. Now the boss must be spawned after destroying the zombies. I'll just go and kill these army, even this one. So now, as you saw, the boss has not being spawned After killing this, the boss has spawned. But the one panel has been displayed because I had not said did that to Zumbi. This will be the problem if you not said the tax Amos that you had entered over here so fine, like a stuck it now on just going destroying somebody's. So where are they? Fine Okay, so now, Okay. Now the boss has been spawned. If we destroy the boss, the one panel will be displayed. Super Bowl. That's it. In this video, if you have any doubts regarding toe this tutorial, you can ask me into this course over. Thanks for watching this video. 9. Building the game for Windows,Linux and Mac platform: Hey, game, develop ALS. So Sankyo from San Sets in this video, I will teach you how to build a game for PC my clinics. So in order to build your game, goto file bill settings and select the PC Mac on UNIX, stand along picks which black form on, then at all the things that you had created. If you have a main middle, drag it to the top so that whenever the game starts, you should load that particular scene, then goto player settings and tell your company name the game name. So, like the icon that you want for your game on. Then, if you want, you can add a splash screen that you want after showing the unity logo on. Then in the bud light and the fire, make sure you haven't told the company. Name s a master abo and even the product Me Just click the black phone that you want to build for and click build if you want to build. This came for Lennox going. Select the target platform clinics on the architecture and click build. If you want to build for Mac. Yes, select Mac on click Build. That's it. Thanks for watching 10. Mobile controls and building the game for android and iOS: Hey, dim, develop ALS. So sound kill from San socks. And this video will set up joystick on the suit button so that we can play this game on mobile devices are an iris. First, make sure you have downloaded the standard assets from the Unity Download assistant on, then go to Assets Import Package on Import Cross Platform Input package. Here we only need the mobile single stick control, so I'll disable dealers pre fabs. Then I click import as we are building this game for Android, make sure you have selected D platform in Bill Settings. 200 by default platform will be said, pacing mark on Lenox Standalone Select Android and Clicks. Which Black phone? Select the bill system Toe internal. Now open stand assets across black from in food input. Pre fabs on dragged the mobile Single stick control. Let's get the jump button. We'll rename this to shoot Button. Do you want here? Will rename this to shoot? Now we'll go back to the player script as we are using the joystick on the scripts from the cross platform input manager. We need to Therefore we're using unity stand glass. It's cross platform input on Wherever you have typed input, we should replace your tasks. Cross platform Input Manager. Therefore, I'll click on three place. I replaced all the input words to cross platform in putting manager. Okay. Even here the world input has been replaced by Cross platform Input Manager. Therefore, this took cross platform input. I suppose cross platform input manager doesn't contain definition. Forget key. Therefore will say get bottle. He went over here as we want to get the shoot button. Which is this thing He'll instead off peak or dogs Beasts We should say shoot even over here. Replace this by shoot. Make sure the name you have endured in the body handler. He seemed as the name that you haven't heard over here Now Lexie, play and check whether this works first. Let's de joystick. And yes, it is working. I'll click the shoot. One more region body And yes, even this is working. Perfect. I renamed this text to shoot. I remember this shadow continent also it is color to black. I'll said the image color to gray. Then I resize stiffened body and even I will change the color off. Fantastic, too. Great! Now you think that We can even stressed a joystick out off the screen to restrict this. Let's go to Mobile. Justic will decrease the moment. Range will set it to 50. And now, if we try to drag out off the screen, we can't therefore address six. The woman trained off the joystick. You can even reduce its size on a line it over here. So now you have set up the on God controls. See the scene. Goto Bed settings on in the Player Settings unit. Enter the company the game. Name on In the resolution and presentation, you can choose the orientation. That is whether you want the game to open in portrait. More landscape mode are in any rotation. I'll select landscape, right? You can even add the icons off the game in the other settings. Make sure you have entered the company Name that the same as this and even do product me on . Then make sure you have Alan all the scenes that you have created. If you have a main menu in your game, just drive it to the top because you want to open that scene first in order to build. This came for Android Goto edit references on external tools over here unit to say, like the sdk pat on the JD compact toe fell like these two parts you need to install and realistic. A Vitz will be available in Android Studio on the Jerry K, which is dollar development kit. You can download this set up and even the under studio, then in Windows, click on growth over here at the top. Type up data. Select up data. Go to local and right on Select the STK for for the Jerry K. Goto Program files into 86 open the job before order Select D J K folder. And yes, if you're using Mac, you can't enter update AS and Windows just open the under studio Press the Andro studio menu in the toolbar. And so it's for android sdk. Then copy that location and placed it over here. No, you have set up all the things. Just go to a bill on Will you again. You can even build your game for the Irish device. If you have any doubts, I think you know what to do. Yes, joined the discourse over and asked me there. Thanks for watching 11. Implementing Applovin Ads for our game 2: Hey, game developers. So Shankill from San Sods in this video will see Hotel Implement App Lovin Acts for our game In orderto implement a player. Nats goto up 11 dot com If you have an account, just click signing. If you don't have just click, sign up Andi. Great an account. After signing in, you will be in the same page, so just go ahead and click on getting started on indignity. Sdk. If you want to display ads on android devices, just click on Enron on Download the Unity three D package. If you want the show ads on IOS device, just download this package. Go back to Unity and create empty game object on call. It adds controller at a new script, good on college tax controller as well, and then make sure you have added as controller to the main menu. As I have not created main menu, I have added here on then open That's controller in the ads. Controller First will create our private constant strength. It's naked key. We're saying that that's private because we are not axing this in any off. The scripts were saying it as Const because this value will not change, and it will remain constant for this sneaky copy necessity. Kiki, over here! Andi based it over here. Make sure you have enclosed within double invited Comus on first, we need to set the Sneaky, therefore with the app loving dog said It's Nikki on well past the Nikkei. Keep as that argument on then we should initialize. They're sticking by saying at loading dock initialized sdk. If you want to show industry shell in your games before showing the interstitial, we have toe load it. Therefore with Sapelo in the pre lower interest issue. And even before sowing the rewarded interstitial, we need to load it right. Therefore with the up 11 dot load rewarded interest issue. If you want to show banner in your games in the start method, you should say Apple windows show al uploading dot Add position center on up 11 dot add position. But now let's create a public wide load rewarded industry shield. We're seeing it as public because we can call this function when player clicks the button or anyone. We can access this in other classes, other scripts before loading when you to check if the interstitial is ready therefore in this condition will say if app 11 dot is incent interstitial ready If the interstitial is ready, we showed rewarded interstitial. If it's not ready, we'll make it ready by saying Appleman dot lords rewarded interstitial If you want to show industry shell, create a public wide calls So industry sha before showing the interstitial we need to load it therefore in the condition which will check whether it has been loaded before the condition will say apple when dot has preloaded interstitial Which means have we loaded our interstitial? If yes, we've also didn't s t shirt If not, we reload interested on Then we will call sure interstitial function again so that to check whether it has been loaded If yes level So the interstitial even over here we load the interstitial Then we'll again called the lower rewarded interstitial function and awarded industry Asia will make you on more money than the banners Andi Regular industry shoes. You can even reward the player When he asked what's rewarded videos? If you want to reward the player desk, click on Rewarded videos which will be available in the docks on then copy this whole thing and placed it in your cold in the start method, make sure you have end of the school London Placido payment, which will be the name off the game object to which you have added D script on over here. When it's a slow did rewarded. Just reward the player by adding extra momento, the account or the extra help if you have 100 scenes or more than 100. Adding this as controller scripts toe every scene will be a difficult task, therefore, will make a single turnout up it to make a single turn. First we have to say private static the class name, which is as control than the variable name. I'll say that instant static because it is not going to change in the abate method I'm calling Make Singleton function avec matter is a method which is called before the start function in the Make Singleton method. I'm talking if instances not equal to know initially, instances said to know, because in the start on Darby function, I'm not assigning the value for it. If instances not equal to know now initially it is equal to know, therefore it will goto else condition we're setting instance equal this we're setting the value for the instance as descript now instance will be the script. And then we're saying, Don't destroy on Lord Instant. That means we're not destroying this object when we go from one scene to the other scene or from one level to the other level. If there's already now instance, has been set up now, instances not equal. Don't know. Imagine you have other Descriptor Amendment. When you start, the game instance will be the script on. We're not destroying this object when you're returning back to the main menu. It already contains are as controller script, therefore, at that time instance, will not be equal tonal. Therefore, we are destroying the game object to have only one script in a game. Reload rewarded interstitial every 100 seconds. Therefore, in the start, matter will start, according we'll call it Show up and over here I'll trade according and call it I animal later show. Add inside this as a origen new wait for seconds inside this I was 100 because I wait for 100 seconds on. Then I will load the rewarded interstitial. Therefore, I'll call load rewarded interstitial function, which is this thing on, then, after showing the rewarded interstitial al study coating again to wait for 100 seconds and then load another after 100 seconds. If you want to show only interstitial, just call the show interstitial function over here. If you don't want the banner, just remove this line off court on. This is not lordly. What industry shell? It's lonely water industry. She in. Now we have set up as controller for again after the ad has been displayed in your mobile. Your application will be displayed over here so it will display the application name on the one light and if I click on it and here you allow the basic settings. If it is not being displayed on your mobile, just anybody test more on wait for 30 minutes, then re Tuckett. And also, while uploading your app to the APP store to any website, make sure you have disabled this because if you enable the test more, you'll gain no money. Here. You can choose the things which you will need on over here when you display the awarded video by default, it will be said to us, which means before playing the reward of video and messages displayed. And after playing the reward video, another message is displayed. I don't want to explain in my feet. So I was like, No, if we acted s on if you want to display message Just entered the currency name on the reward that will reward the player. After watching the video on, he said, If you're building your game for Android on, If you have implemented the Apple Onex before building your game, just go to plug ins on road and open the android manifest Fight on, Then just go to file their settings. Click on player settings on over here. Copy the product name that you have entered on based it over here with this back his name and then you how toe pace the sdk key over here. Just service and back to unity on then build. Yogi, if you did not enter your app planned on the STK key while building the game you're a survey later so therefore it is necessary to enter the product name as the last. The sdk key 12. Where to support me: Hey, give them both. So Shankill from San Sauce and this video will take a look at how you can support me to create more tutorials. First, if you like my way of teaching on want to see more classes or courses, just follow me by clicking this follow. But then you can also support me financially. One waste by going to my website. Sansa. It's not It's not I o on on my website, you can click on any off my game, for example, shape. It's here. If you click the download button, a window will pop up, asking you for the support over here. You can enter the desired amount on Rosie are. You can go to people like me slash testicle a seven on their support. Me. You can even transfer money to my PayPal account by using our email. But is she? She promotes seven at gmail dot com. Are Goto patriot on your corn slash stance? Odds on their support. Me are goto patriot on your corn slash stance. Odds then become a patri on. After that, you can support me through patri on in Patriarch. You can support me or donate me monthly for the tutorials I make. You can cancel it at any time. You can also support me by joining my discourse server, which enables me to grow my server. So in these ways, you can support me to create more tutorials. Thanks for watching. 13. Where to ask doubts: Hey, game. They'll oppose the Shankill from san socks. In this video, we'll take a look at where you can cloud for your doubts with me when you enrolled in the course. I don't do community on. Take on. Ask a question. Type your question on Glick Post for faster Reply disco. Discard up dot com. Create your account By clicking on this button, you need to just enter your email address on, you know, to enter the password for your discord accounts. This court is a chatting up similar to water. Here. We can discuss things related to game development on. You can clarify your doubts over here after you sign in to join my Celo. Just go ahead and click on this place button Select, Join a Sobel on over here, Type this league. Don't worry. This link will be available in the course description. Just copy that on base it over here are that it will be in my Flink on. Then create your account to join my silver. If you type this link over here, just click. Join on, then you'll be joined to my server. Now take on this developing story space run a game in unity, which has stream or options there, select help on then you. You can type your doubts so that I are. Other developers will clarify it. If you want to chat with me or other game developers, just click on SAT on Type your message. You'll not be allowed to enter this particular channel because I have to add your role so that you will be able tow access this particular channel if I want to give you a role just just and lasting science arts. Click on sat with sense on over here you type at Shawshank Creator off sand socks on. Then type your name, which is seem as your skill chur account name on. Then type the course name or the class name. That's it when I will be on line. I love you rule so that you can access this particular channel or a particular channel, which has same name as the cause Me. If you'd like to follow me on skills here, you can do that. If you complete my course or a class, you can just tell your review as it helps me a lot. Thanks for watching