Learn Unity 3D and C# By Making Games - Course 2 | Rusty Smith | Skillshare

Learn Unity 3D and C# By Making Games - Course 2

Rusty Smith, Learn Unity 3D by Making Games

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
8 Lessons (5h 17m)
    • 1. 2-0 Course Introduction

      0:54
    • 2. 2-1 Project Setup

      15:34
    • 3. 2-2 Player Controls

      30:32
    • 4. 2-3 Bomb Creation

      63:26
    • 5. 2-4 UI Setup

      51:54
    • 6. 2-5 Animations

      25:46
    • 7. 2-6 Boomberman Multiplayer

      50:54
    • 8. 2-7 Boomberman Singleplayer

      77:58

About This Class

Welcome to Learning Unity 3D and C# By Making Games.

This is the second of a 4+ part series where you will learn Unity and C# by making games.

In this Course you will learn how to make a Bomberman like game that includes a singleplayer and multiplayer game mode.

You will learn to create a full game in each course with custom art assets included with each course.

Download the Starter Asset Package from the Class Project Panel upon starting.

Join the Course Discord discussion group at https://discord.gg/9WYC2sQ to discuss anything related to the course with other students and the teacher.

The audio issues found in the first couple of videos are resolved with a new mic and setup after, please bear with it.

Transcripts

1. 2-0 Course Introduction: welcome toe Learning Unity 2017 by making games. My name is Rusty Smith, and I am a unity developer based out of San Diego, California This is the second in a four plus part Siri's, where you will learn unity and C sharp by making games. Over the course of the Siri's, you'll be introduced to two D and three D games over a variety of genres. In Part two of this series, you will learn how to create a single player and multiplayer game to the liking of Bomber Man. You will learn how to animate objects using the animator built into unity, as well as get your first taste of writing. Basic Enemy I. This course provides custom art assets for you to create a full three D game, including animations, audio and a user interface. If you have not already watched Part one of this series, ah, highly recommend that for students who are brand new to unity prior to starting this course 2. 2-1 Project Setup: Hello, everyone. Coffee here. Welcome back to the second installment in the Unity 2017. Plus, uh, tutorial, if you are just seeing this one and you haven't watched the floppy firefly tutorial first, I highly recommend that, as I will be going into things more in depth in that tutorial and less so in this one. If you have completed the first tutorial and go ahead and create a new project here now, I went ahead and named mind Boomer. Man, this is going to be a bomber man like game that is going to include a single player and multiplayer game move. The multiplayer game mode is going to be two players on one keyboard and we'll allow you to set. He binds to whatever you like. So once you get your project created and unity pulled up, go ahead and download and import in the Boomer Man start up package that is included in the beginning of the projects or in the project holder. Let's go. And polar over here. So we have our number. Man started here. Double click on this and this is going to import in all of the audio and art assets that you need as well as some starter scripts that will help us handle the scriptural objects without having Teoh go into death with training everyone on how they're rated or exactly other work that will include it. A further lesson will start to dig into a little bit about scriptural objects with this game and start creating our own scriptural objects with some more advanced features in Vernon tutorials. All right, now that we've gotten our basic assets in court Vendor project, first thing we're gonna want to do we're gonna go ahead and create the floor level or the project. So let's go ahead and right click here and go toe three D object. And we're gonna go ahead and create the plane you have named this floor. And for this floor we're actually gonna do is we're actually going to position it. We're gonna offset its position by about 25. So we're gonna change its position to negative 0.5 or the 1st 2 and then we'll leave it at 20.5 for the Z axis. This will make it to where, when we're actually placing or other objects, will be able to place them directly on the whole member coordinates so we can place things right at 11 instead of having to have the paint lacquers. So while we have this for the, um, render itself, we're not actually gonna want to use the evolved material that it comes with. We're gonna want to use this grid pattern we have here and textures. So the first thing we're gonna want to dio in order to get a new material placed onto our floor here is we're gonna goto our materials holder. We just right click on the folder we can go to create, and you can click Words is material, and we're just gonna leave. This is a standard opaque, um, material. And then over here, where it says albedo, you go ahead and click on the circle here, go ahead and select from the textures that are already in the project. And go ahead and select this grid to color. And then we could rename this material to four material. Then you can double click on a, um, any item you name it. And then once we select the floor here, we're gonna grab this more material, and we can just drag it over the hold the materials out here, you can either click the circle here or again. Just drag and drop it over the depo materials here, and you should see it. Um, pop up right here in both your scene and game of we're actually gonna want to do is we're actually gonna want to change the tiling on this material. So if you click the, um, little Chevron here, this will actually go down. And we're gonna change the tiling or the primary tiling five by five. And then you don't change anything with secondary tiling on. And then that should be the proper tiling size for what we actually want for a project. This will actually make it to where each block will be taking it. Exactly one of the squares. So the next up here, let's go ahead and change our camera to the on direction Rex you're gonna want from within the game here. You can actually go to our main camera here on and actually go to the main camera here. We're gonna leave it. It's perspective. And let's go ahead and move its position to, um, negative point to well changes. Why? To 18.3 z 2 500 or field of you were gonna go and lower this down 30 and then for the rotation, we're actually gonna rotated on the Z axis or on the X axis. And as we get all the way down here working 70 years where you're going to get this top down view that we're gonna have here that will end up looking okay or the Claire's and change this year rates. And so this is actually gonna be okay here The this bottom square is actually going to be in outer edge. So you don't actually worry about the fact that it's actually a little bit here has the how the circles were actually going to be covering up these outer squares where we're seeing here. So now that we have the floor in place and the camera set up, how we're gonna want it to be, the next thing we can go ahead and start to do is actually create the block. So let's go ahead and just right click here, but a three D objects and we're going to go ahead and make a U. And you know, this year right away, because of the way that we position the floor. The cube itself is already in a perfect position. It doesn't need to be lowered or raised or anything else. So we can actually dio is for this cube instead of it. Being a solid weight we can do is we can actually change it. And we're gonna go ahead and create a new material for the block as well. We're gonna go ahead and create material again, all the clock material. Then we can change the color on this. Never mind. I'm just gonna make mine a darker blue here, going back on a cube here. Well, reading block. We're just gonna attach this new block material right to the project itself. So no, we have our block. You can actually dio is position these where roughly very well could be. But let's go ahead and walk off the entire outer edge first. So they have our block here and actually dragging over here. You see? Feel what? Turn around. Our are seeing here so that this is consistent with hammers removed. Um, this way with camera is gonna So the exact coordinates that we're gonna want You're gonna want these on or even numbers. So now that we have this, let's actually build our walls, make sure that our characters aren't gonna actually fall out of. So let's go ahead and making new empty game of care. And we're just gonna call this walls. This way we can compare everything to the walls self here, We'll offset this little bit losses this week 15 as well. Zero and high. And then let's go ahead and create objects underneath this so we'll make another cube. Allow this one, um, law we're gonna want Dio is going to catch the same block material to But for the position of this, we're actually gonna set this wall 5.5 and then 2.5 and then we're gonna change this the Z scale on it to be alone. You'll see here that this is actually going to be, um I guess we can call this. He's well, So you see these walls, the ones for the east and West walls are actually going to be, um, by 11. And then the walls on the, um, other side are always going to be 10. So the disease well, here you can go ahead and control de greening last fall. And then we're just gonna change the exposition on it all the way over to negative. All right, then we can actually just it controls you on this again. This one too. So? Well, then we will make this one to be on the one on the easy access where we're gonna change to 10 on the X axis and we can go and position is down here. I want to be. I was going to end up being zero and negative again. Control de hoppy this up to the north wall, and then we'll just change its position. Who ended being five. Get that same offset that we have with they other side. No, we have our or walls here. All right. Now that we have our roles in place, we can actually go ahead and place all the blocks that were actually gonna have when we can actually move these. And let's just make a nice uniform creep pattern first. So we'll start appear in the corners, is making three and four, and then we can actually copy these. Just make sure you're it's a place. Go ahead and select the object again down here in the hierarchy, it controlled D, and you can actually just slide it down on. And, um, you'll see that the actual units are gonna just be moving in a uniform manner. So again, copy it again. And this next one you can just changes to zero here, the next one handsome for going down right now. We're gonna change Z today to the last one. You hear? If you actually dragged the walls up, you can get him way here. Intuit these other three or four blocks here we go ahead and hold ship. It's like for them at once making just control de on these, slide them all over. We're just going to change the X value on all of them. So we're gonna change negative one. Then we can even just take all eight of these this time and control the again. We could drag all of them over on, and with them in line B will probably want to select peaceful of the time and make sure these actually exactly where they need to be. So this is the 0.9 will set it in one. In the last four. We're gonna make sure these are exactly All right. So now we have our blocks in place, depending on how you want the shadows to be. We're actually gonna one do here if we actually go ahead and click courses. Directional light. We can actually change the rotation of the light here. And that will affect how the shadow there So we want Oh, is the increased the amount shadows there are being again Change the petition, change the tradition on the of the by access or on the the access, the excesses and changes much. Pretty much the x and y axes they're going to control. Um, kind of where the shadows air. So let's go ahead and move these a little No, we'll just leave 16. We'll leave the shadows the place for now. And then again, we can change the, uh you can change the strength of the shadows of you want to lower them, um, or you can change the intensity of the light something a little bit lower if you want a little bit more light. Well, our mind to about point. He just Teoh ensure that the colors needed. So, um, now that we have this first these things built. Go and hit control ass and let's go ahead and save the scene. We're just gonna name this scene to the multiplayer scene because we're going to be making to seem to the person they're gonna make is gonna be able to play I've seen. So let's go ahead and see this now And that's actually gonna be it for this first video. In our next video, we're going to be creating our player as well as the player brain, which is going to handle all the controls since we're going to not want to have to duplicate, um, we're handle the players differently for player when a player, too. But we need to use the scriptural object to quickly and easily set the Haughey's for the controls for the players because we want to change him. And once we have the players actually able to run around a move, then the next step from there will be to handle the creation of the bombs. See you in excellent 3. 2-2 Player Controls: Hello, everyone. Welcome back on today's episode, we're going to continue with our Farmer Man project. In this episode. We're going to be creating the player as well, Aziz creating the player brain, which is going to be used to control the player as well as be designed in a way that we can easily implement a second player on the same keyboard. So first things first, Let's go ahead and go to our scripts. Holder here, go out and right click. Go ahead and create a new script. We're gonna need the script player brain, and then we can go ahead and just double click on this and open it up in visual studio. So in our case, we're going to want a few things in our player brain class. The first thing we're gonna want to do is we're actually gonna want to change this to be a script herbal object. So we're gonna be setting parameters for this outside of the game itself, and it doesn't need to be actually in the scene itself. It all subscript herbal objects are containers for data and information that don't actually have toe actively be put into the scene. They could just be access for memory. So, um, we're gonna go ahead over the top here. We're gonna go ahead and write. Create asset menu with this is going to do is make it to where, When we go back into unity, we can actually, um, go to right click here and under create. We'll see player brain pup appear once the sexually gets loaded back in, you should see a player brain pup appear next to all the other, um, scriptural objects that we have. So let's go ahead and get back into the actual one that we have here. You know, when I hadn't seen this yet And great player brain, There we go now show no. So let's go ahead and go back into visual studio here. So we're going to have a few things here. So, first or the variables, let's go ahead and we're gonna add an int player number. So this we're going what we're going to use to determine whether this is player when a player to and then we're going to add a new game object which will name player go. So this is gonna be the player game object. So the actual player that this brain is connected to. And then we're gonna add a public flute variable, and this is gonna be the player score. This is what's going to be used to actually track the score between each player between scenes or if the scenes get reloaded and the marina said a public float variable and we're gonna set this to Max active bombs. So this is what we use if we wanna quickly adjust the settings of our game. So say if we want the maximum over problems to be three is what we're going to start with. But if you want to change it for your game, your this will allow you to quickly and easily do that. So we're gonna had five different key Bynes. So we're gonna use a public key code. We're gonna call this one up key, so this will be to basically control go up public key, code down the like he could do you Lookie Code Breaky. And then we're gonna add one Final one for public he code and the bomb. He will be used. Teoh, drop the bomb so we can't even in this year, we'll just leave it is, and then we'll make a We're gonna want to have a variable to control, um, when the player is ready. So we're not gonna want to actually start the game or start the match until both players have hit their button state that they're ready. That's good and at a public pool ready and want to send it to the false by Defoe. And then we'll go ahead and add a public color. Call this light color so we can use this to determine the color of the player, but we want them to be the default. Will decided to green for now. If you want to set player one to be default a different color, this will be the color that the player will be on single player. But you can adjust this again by having this year in this, uh, player being player brain area in Oregon at a public float. Variable movements be so what we're trying to do here by having the float variables. Um, both player one and Player two will reference the same foot variable. So if we're gonna change the movement speed, it's gonna adjust it for both players without having any without us having to change it in more than one place, and then we can go ahead and we're gonna make a public came object here on this is gonna be the bomb prefab. So once we actually enable the player to be able to actually drop bombs, we're gonna have a reference to that bomb. So we can actually instance she ate copies of that from there and then for the bomb itself , we can determine how long of a delay, Um, the, uh, player will have between actually placing bombs. So, buddy foot variable here had the bomb placement delay and then for that since will end up having a, um, public float here called Next Bomb Time. Set it to zero by default. This is gonna be used based off of the actual bomb placement delay. It'll just take whatever time the last bomb was dropped and then add the bomb placement delayed to it to determine when is the next time that the player can actually drop a bomb with them. But they want to set this to something. Um, you know, 100 or 200 milliseconds just so that the player doesn't actually dropped more than one bomb at once. And then the last thing we're just gonna add a public. Um, actually, we're not gonna add. They say we're gonna go do just go ahead and come in on direct to Dio had active bombs list . But we're not gonna have the active arms list yet because that's going to require us to actually have the bomb is created, which we haven't done yet, so we can go ahead and get ready to start an update Methods cause when I actually going to use those, But let's go ahead and add a new void here, just a new private way called on enable. And what this is gonna dio is a soon as the, um, brain is actually enabled, um, or brought up, then this is going to resets of variables for us. So we're just going to set this to next. Bomb time isn't equal to zero. This school, it's gonna reset that it's gonna set ready back to false as soon as the, um seen starts every single time or as the player brain is enabled. So let's go ahead and go back into our game now and let's go ahead and go down to our variables folder here. And let's go ahead and create the variables that we're actually gonna need here now. So the ones we're gonna need, let's go ahead and create a player brain when we can just call this one player one brain. And then let's go ahead, make another one as well. Another player brain player to bring. And then we wanted to have a little very boat is gonna be player One score. We're gonna add another one for player to score, player to score and then each other ones will be shared here. So making other float variable here. This will be the max active bombs. It's good. Make another one here, variable. We need a movement. Speed this player movement speed. No way. If we want to specify and add one separately for an actual, um, NBC's for single player mode, then we can just that as well, and we'll create and we'll make another one as well. And we'll set this to the bomb placement delay on. That should be it for the actual variables we need. For now. We can adjust these at a future time, yet all right, so Now that we have our variables created, we can actually go ahead and start to set some of these default keys here before we move away from this for a player. One. Let's go ahead and set this player one. And let's go ahead and set the player score will go and drag player one score under there. Um, except of bombs will go ahead and drag and drop our, um, power reference into their same for the player movement, speed, and then the bomb placement delay when go and drug these in here. So whenever we actually just these values later, it will automatically update him for the player character here as well. So let's go ahead and set the keys. I'm gonna go ahead and just set player one to just use aws d. So for up, we're gonna want to view. Um good. Good on s here. Left the a right D. And I'm just going to set the bomb key to just be, um, space bar. Perfect. Okay. And then, um, we don't have to save anything because he saved themselves. So let's go to the player movement, Speed. While we're at it, let's just go out and said this to six Set the Max active bombs to three for starters, and the bomb placement DeLay will set up the 0.25 So we want to basically limited to every 0.25 seconds when you can actually drop a bomb that way again, players don't actually dropped more than one bomb at once, getting always increase that time if if it's not working out on your version of the game. So now that we have the Bring created, let's go ahead and created a script for the player and then we'll actually create the player itself. So let's go ahead and create another C sharp script or it's gonna name this player and then let's go ahead and pull this up here. So we're gonna want to add a few things to this. We're going to be using a rigid body to control the character, so we're going to go ahead and add a public rigid body. Well, just name this rigid body. This is going to overwrite the rich body class that's already here. Um, we can actually just, um new rigid body, A new rich body, Richard body. This will just overwrite the default class that's already there. Um, that's being inherited by model behavior. So and then we're gonna add a public player brain this name, that spare brain, and then we're just gonna add a new couple private values, which is gonna be attorney and new rotation. This is gonna be used toe on every update frame. It's gonna determine the new rotation for the player, and then we're gonna do a Vector three and new velocity as well. These will be used to actually set the player, Um, whenever it is, whenever they're actually going to move. So these are all we're gonna need for now, Um, later, we're gonna want to add in a good and just do it to do here and then, um, ad animator. And then, um then we're gonna do wanted to do a to do at light. So we're gonna want a light on the player that will just be taking whatever color is on the player brain and that they will make the light actually display that color. So what, We're going to go and do here, You know, we can actually just have the light right now, so let's go to make a public light, and we'll just name this player light. And then so during the start, where ranks to be doing it to be any of every scene as we're going to take the player brain that is connected to the player when we're gonna set the player game object equal to the game object that this script is on And then what we're also gonna do is we're going to take the player light, and we're gonna set the player light dot color equal to the player brain. Not like color. So this is gonna make sure the colors match upto whatever we actually set on the player bring itself. So let's go ahead and had the movement here. So two important things to note when it comes to handling a player movement, you always want to be handling player inputs during the update because that's gonna be called during every single frame. So that what you're not missing player inputs. And then when it comes to actually handling player movement, you want to be handling that in fixed update so that, um, the movements me to the player isn't being limited or um controlled by the FPs that the players getting because otherwise, players that are playing on a worst machine that are getting lower FBS the game will be running much slower, and the player will be moving much lower or vice versa. So we're gonna go ahead and add a void fixed update here as well. We're going to use that to actually handle the player movement based off of the inputs that the player actually receives during the update frame. So let's go ahead. And for now, let's just during the update frame here, we're gonna go ahead and do a, um we're gonna go and check it to see if the player is holding down any input keys. So we're gonna do it if input Dr Key and we're gonna set this two player brain dot up key. So if the players holding the up key, we're going to go ahead and set the new velocity equal to a new Vector three, we're gonna set that 00 and then the player brain and dot movement speed. So to move up, we're gonna be moving on the sea access. So, uh, we're gonna movement speed, not value. So this is actually going to set the, um, philosophy for the player, um, to be based off of the, um it's gonna move on the Z axis for up or down. So and then we can also do a on. And here we can do a, um if input get key later. Brain got down Key again. Said this one to be actually wanted to reset the rotation on the player as well. So let's go back here into the rotation equal to attorney and dot Euller. We're just going to reset this 2000 So that would be just said it's looking the default direction, which will be up. And then we'll adjust the directionality of the character based off of that. So for the down key, the new velocity is gonna be equal to a new vector. Three 00 and then negative, Claire Brain. That movement speed dot value. And the reason is that the new rotation you go to a return ian dot Euller, we're gonna set this 201 80 0 What is going to do it? Make the player flip on the, um why access to rotate looking towards the camera. So the Euler that returning that Euler is basically setting the internally attorney in based off of the Euler angles, which or what you see in the inspector with immunity. Um, this is the easiest, um, wait to work with Kryptonians and kind of the only way that I recommend for players or for programmers. Just because unless you I have extensive experience with calculus than Kryptonians are just gonna be far more than what you actually need to know in order to use them. So we'll just stick with the Euler angles for now. And then let's go ahead and move to the next keys as well, instead of retyping all of this. What we can actually do here? Yes, we can actually just copy pace. So it's good pace down here will set this player brain right key. And then we'll set the right key here to be 000 and will make this one to be the player brain that movement speed value. So to move right and left, we're gonna be moving on the X axis. So for, um, the to move right, we're gonna be only turning 90 degrees, and then we also want to be moving on the X axis and then we can go ahead and paste again for the other one who are against that. This to left G, and then the sun again will reset. The Z value is not gonna change. But the exact X value is we're gonna send this to negative player brain, the movement, speed value and, um, zero on the Y NT excess. And then we're actually gonna be turning 270 degrees. Um, in order to get the player to be looking left. So in the last thing after we determined the, um, direction, the player is gonna be looking at moving based off of what they're cooking, we're gonna want to do a final one, which is going to be an if input get key player brain dot funky. Then we're gonna go ahead and drop the bomb. Um, so we're actually gonna want to dio we can actually just set this right now to be, um, in a future time, we're gonna use what's gonna be called like a state manager. We're going to use that to determine whether or not the game is actually active, because we don't want players stopping the bomb before the game is actually started. So well, do they to do, add, um, state manager. We'll come back to this in a bit. And then, um for now, we'll just have the bomb key. Dropped the bomb, so we'll just go and say this. And what is that? A new, uh, boy done here? Drop on. And then we can actually fill this in later with what we actually wanted to dio as we actually had the bomb. But for now, let's go ahead and finish movement. And then, um, we can't even just do a consul or debug brother debug dot I will set this to, say, dropping bombs, and then that way so we'll know that the drop monkeys actually working for we wanted to do , even though we're not actually gonna be dropping a bomb at this time and then for the fixed update is where we actually want to handle the velocity change in rotation change that was determined based off of the keys. The player is actually hitting. So down here in the fixed update, we're going to, um we're going to go ahead and check to make sure the new velocity. So if the Actually, we're not gonna take anything because we have no state manager. Yeah, so to do at ST Manager, I'm sad that this here is. Well, we're going to go ahead and add a rigid body. That velocity is going to be equal to the new velocity, and then we're gonna add the transformed rotation is going to be equal to the new rotation . And then let's go ahead and reset the new velocity back to, um, vector 3.0. So that's actually something we wanted to check for. We want to check if the new velocity is not equal to vector 3.0. Then, um, we want to actually set the new velocity, because otherwise this is gonna be overriding the speed of the player. Um, before we actually, where the player is not going to get the full movement that they would, um or that they should be getting. It would actually be resetting after a frame. Um, if we have the philosophy being reset and instantly replied, So let's go ahead and go back into unity now. All right, so now that we're back in unity, let's go ahead and create the player itself. So Let's go ahead and make our new player. For now, let's just go ahead and, um had a capsule so you didn't go to create here and we are going to create a new three D object and we're gonna capsule, and we're going to go ahead and set its position here. Let's go and raise this up. And what's going to the position on the capsule to be Let's get this 240 and five. So we're gonna just some size. It's here on the capsule because it's gonna be too big as it currently is. So let's go ahead and adjust this here down under the capsule collider. Let's go ahead and change the height to just be one instead of two. That way, we can, uh, just this year will leave the why, actually it zero. So the my surrender. Okay, so the mesh render itself. It's just, uh, falling through right now, but that's fine. We can just let it fall through when we change the model. Then it will, uh, actually get adjusted. Actually, what we can do is for the mesh. We can actually just change it to be the player will mesh over here for now and then, um well, actually move this when we actually add animation. So McGinnis said this current one right here for now, just change it to one of the player models and then, um, apply one of the pallets to it for whichever color you actually wanted to be. We'll just set it to whichever the 1st 1 is here. Here. So this is gonna be the red Player, but that's okay. All right, So now that we've actually added our capsule here, let's go ahead and name this to be player one. Then let's go ahead and add the player script to it. And then for this for the rigid body, let's go ahead. And, uh, we need to add a rigid body to this as well. What a rigid body to the player here. We'll just drag and drop this onto our player script for the player brain. Let's go ahead and at the player one brain. And then let's add a light component to our player as well and actually changed. The light here will change the believe it is a point light, but let's lower the range on this to quite a bit less cherry 1.2, and then let's test to see what it looks like. A green. You really see much right now, but we'll just leave this and will change the intensity of the something a lot. 10. I like that. It's very bright. Makes it easy to track the player and the beads. It actually see where the player is when they're moving, so we can go ahead and save this year. Now and now when we go into the player light here if we don't set this than it'll actually air out because we didn't set anything in place to check to make sure there's a player, brain and, um, player light value set. So let's go ahead and save this and let's go ahead and start her scene and see if we can get the strength so we can actually use our player controls here to actually move the player. But again, See, they're actually fallen over off of the momentum were given them. So we're actually gonna want it, um, a NPAs game here and we're gonna actually want to go to the rigid body here and click on this chevron here to pull down the constraints, and we actually want to freeze the rotation on the rigid body itself. We don't want to it to actually, uh, be allowed. Teoh wrote it all, and we actually want to turn off the gravity. And then we actually probably want to turn up the dragons. Well, so turning up the drag will just increase how much faster the player will stop after they've received movement or received some amount of, um, velocity change. So we can go ahead and save this. We can change the collision detection to continuous as well. It would just make the physics engine focus a little bit more on the character to make sure that we don't actually get any missed registrations for collisions. So now that we've changed the rigid body, too, not rotate what's going to play again, we should see here that we can actually move the player here now and they're turning. So when we hit up there turning and looking forward, and then when we're hitting down, they're actually moving backwards tourists and turning around in there, turning in each direction right now. So, um, as you can see sometimes when we're going at the corner. We're getting getting lifted up a little bit here. Were able to rather So we're actually gonna want to dio The last thing we're going to do in the studio today is we're actually gonna add just a little lid above the, uh, boxes here. We're gonna scan at a flat, transparent box that's gonna basically contain the player to ensure that they can't actually go up and over the walls on accident in case something crazy happened. So let's go ahead. And, uh, and that scene there and just here under our walls, let's go ahead and, um, take one of these other walls and let's just go ahead and do a control D on this. We're gonna copy this wall and let's go ahead and move it over here a little bit. And let's actually get rid of the mesh render for this one. So we're gonna go and remove the render and rex you're gonna do is we're gonna change the scale on this to be, um, 10 by 10. And we can actually move this. Let's just make it 11 by 11 just to make it easier. 11 by 11. So we're going to do is this is actually going to be basically a cover that goes over, um, the entire map here. So I think we just want the height actually be exactly one. Um, And then that way it will ensure that the entire map has actually covered, and we can't actually get the player lifting up all anymore. So if we save this here now, we can actually let's rename this to be, um, the roof here. We're sealing whatever you wanna call it, and then let's go ahead and hit play. And now we can actually see that the player can't actually get lifted up, uh, anymore, even when they're turning the corners and they get lifted up a little bit, um, they're actually hitting the ceiling here so that we don't actually run into that. So now we have the player moving around in the next video, we're gonna be adding the actual player bomb toward the player can actually, um, where the player can actually get hit by the bomb. Um, as well as drop the bomb. So, um, yeah, actually, one more thing before we do this, let's make a little adjustment. I noticed the players getting a little stuck here. So one of the things we can actually dio so we can actually change the radius on the, um on the collider here for the player because it's so close with it being exactly 0.5, it's actually squeezing in their very precisely. So if we actually change, that's the point. For 95 what we can dio is the player should move a little bit more cleanly around these corners without getting caught on the edge as much. You can make this value a little bit lower if you want to. Player to be able to kind of, like, um, turn its way around the corners a little bit easier or kind of Ah, I guess glide around the corner is a little bit easier. Let's go ahead and even let's check like a 0.45 and see how much of a difference this makes . Or if it seems like the players moving left to right too much or too wobbly. Um, yeah, these can be played with them. We can adjust the models later, but for now this will get us what we're looking to Dio and then in the next video again will be handling at the bombs as well as adding the second player and the state manager in order to ah, get a little bit of a game going on. Perfect. So, um, thank you for watching on. I'll see you in the next one. 4. 2-3 Bomb Creation: Hello, everyone. Welcome back in today's video, we are going to be creating the bomb. The player is going to be dropping as well as starting to set up the functionality to actually control the game state. So first things first. What we're gonna want to do is we're gonna want to go ahead and create a new empty object. This is actually gonna be our bomb. We're gonna go ahead and create our bomb here. We're just gonna need a bomb. And then underneath the bombings were actually going to be putting the mesh for the about myself. So we're gonna actually making a spear down here is gonna make it easier to be able to control the scale of the bomb itself and control some particle effects later on. Be able to scale them down without having to actually just the scale of the object, the main parent object. Rather. So as we take the bomb here, we can go ahead and just test it. Zero. We'll just change the position, Teoh. Solid numbers as we look at it here in the seeing view and under the spear here itself, you can actually just mean this to be mesh. Let's actually change the scale on this down a little bit. 2.8 on each. That way, the bomb is just gonna be a little bit smaller. Um, then the, um then the world itself. That way we can get some particle effects and other lighting effects to actually showing a little bit better. Under the measure itself, we can actually change the material here. We do have a bomb material around here believe already created. If not, you can actually go ahead and make one. And what we can actually dio is let's actually just make a bomb material. So under the materials tab here, let's go ahead and just right click and go to create must make any material. We'll just call this bomb material. Um, we can just even call this, uh, bombing to you. There we go. Little scholars. Player one. We're gonna change the rendering mode here. Too transparent. In this way, we can actually set the color on this too. Will decided to green and they were actually do is change the Alfa value to maybe about 25% or so. Let's actually go back to our bomb now that we have this major. Let's actually attached this new bomb material. That way we can see what the bomb actually looks like. So we're gonna want this to be a little bit transparent at first or for this one Because, Aziz, we have a timer for when the bomb is exploding. That's going to be a secondary color that's actually going to be filling up the bomb. So as it starts to get closer to explosion, you'll see it actually going opaque and actually filling in the color. And that's when I will actually explode. So we'll be able to kind of give the players a bit of a warning that they are going to explode. So now that we have the bomb created, what we can actually dio is get this set up to where the player itself will actually dropped these bombs. So let's take the bomb itself. We can leave this year unless we should go to script. So let's actually create the bomb script to know. So I got a great C sharp script. We're gonna go ahead and make a bomb. So we should see this bomb script actually get loaded in here now and for the bones, Kurt. It's gonna have a few things. First, you're going to end a batting, a particle system, so we can actually add the things that we're gonna actually using up here right now. So we're gonna look all this mean particle, We'll make a public player brain. This is gonna be the player that is actually controlling this specific bomb. So we'll call this one our brain, and then we are going to have a reference to two dio state manager to do a game imager Long is gonna actually want references to both and then we'll make a public variable. We'll call this bomb timer length. So this is what we're gonna use to actually determine how long each bomb will actually take up for before it explodes. We'll do a public float explosion tick. This will be used actually determined when it will set the time based off of the bomb timer length and that will set that as the explosion tick and what it actually hits that during the update frame is when it will actually explode. So then we'll at a pool exploded live. Is it true for a default? Then we're actually going to. We're gonna end up pointing that sound to our bombs so that a public audio source we'll just call this audio source and then we're gonna have a couple of audio clips as well. So we're gonna have the audio clip, which will be beeping sound, the bomb and a lot of public audio clip for the explosions out Well played. You sound independently as it is getting closer and closer to exploding. So we can actually, ever to this start method because we're actually gonna want this to, um, function on on enable instead and as opposed to just when the scene is starting we wanted when the bomb itself is actually enabled inactivated so on, enable What we're gonna want to dio is we're gonna want to so to you will just put the particles on systems for now. Let's just go ahead and add the set exploded. Put the false and then, um, we will check if this bomb has an owner brain because there's gonna be neutral bombs at some point as well. They get spawned and those won't have an owner. Those will just basically be able to do damage to anybody, and they will be not owned by any particular person. They'll just be there, kind of with If both players air surrounding too long in the game will start escalated, start spawning extra bombs to try to kill somebody. So for the owner brain, if it if the bomb actually has an owner brain, then we'll do Owner Brain, we're gonna given ad active bomb. And we'll just told at this so we actually go back to our player brain script from here. What we can dio is we were at a couple method to so before where we had our let's go ahead . So here's what We're gonna have these active bombs. So making public list bomb, This is gonna be active bombs. Who? Eagle to new list. So we have a list of bombs. Here is where we're gonna use to determine whether or not the player already has the maximum number of active bombs. Trying to drop more will limit them. So from here, we can do a public boy had active bone passing the bomb here, and then, um, we'll make sure that the active bombs list doesn't already contain this bomb, So we're gonna do a check if not active bombs contains balm. Then we're going to add this bomb to this list. So active bombs had you're actually gonna go ahead and make the remove, um, method right now as well. Still public void removed. Bomb. And then we'll do bomb foam here. And this is going to check to make sure if the active bombs list contains this bomb, then we're going to remove it. So active. Start, move. All right, so now that we have the saved, we can actually go back to our bones script here. And then what we can do is we can handle this in the fixed up day frame and what we're going to dio we're gonna go ahead, do a If the bomb hasn't exploded and the time that time is greater than the explosion tick , then we're going. Teoh set exploded, but the truth and they were going to handle the explosion. So we have created this method yet, but we're gonna go and create this right now. So what this is going to do is ensure that because we have the exploded said too true by default. When we first create the bomb, it's gonna go through one of these update ticks, but it's not going to, um, at this point it's not going to have set the it's not going to automatically blow itself up . Assume it is soon as it is creative. So let's go ahead and make our Boyd handle explosion. One more thing that I was just thinking about is up here. Reaction need at the timer for the explosion tick when the bomb itself is actually enabled . So we're gonna set the explosion tick equal to time that time, plus the bomb timer length value. So this is going to set it based off of the bomb timer like that. We actually give it on. When we get back in, Unity will actually create this float variable. And for handling the explosion, just go ahead. And for now, let's just go ahead and at a deep of that law that says exploding. So you will know when the bomb is actually exploding. And from here, let's just go ahead and make the bomb destroy itself. And then just so we can go intestines for now, two story game object after 20.6 seconds or so. That way, we're gonna basically have it sent to destroy itself. It's gonna give itself long enough to actually play. It's animation before disappears. We gonna just this time later if we want to. And what we're gonna do is we're gonna do a going on destroy to ensure that when the bomb itself actually destroys itself, if it has an owner brain that is going to notify the donor brain that it no lover, that it is blown up already. So owner brain with bomb this so this again is going to go back to our player brain function here and remove this from the active bumps that we have, which will allow the player to drop more of them. So let's go ahead and save this for now. And let's go ahead and put this to the test. So let's go back here and go back into our game and under the bomb itself, we can actually add this script now. That bomb, we're not gonna have any particle systems yet, but this bomb let's go give this to player one. The bomb timer length. We don't have a bum time really get so it's good and create any flow variable timelines. Well, let's just go ahead and set this to three for. We'll see if we want to change this later on. Make the bounce pull up a little bit faster. So it was good. Like a bomb here. Well, said this to the bone timer. Length in the audio sores on audio clips. Let's go and exercise. Had the audio sorcery using yet, you know, and added to the bomb and drag and drop it off the audio source. And go ahead and save this. And from here, we can actually take this bomb. If we drag and drop it into the prefects folder, we're gonna want to be spawning these from pre fabs. So we're gonna go ahead and just spawn this for now, Are safe this for now. And when we're updating the prefab, we can continue to update it as things move forward. So let's go ahead and at a, um, the bomb here to the player. So let's take this one specific bomb here. Now that we have this created on the bomb still set, let's actually go ahead and, uh, disable this one for now because we're not actually gonna want this one active in the scene . the only ones we want active are the ones that are actually gonna be dropped with player. So if you go back to the player brain here, we should actually have the bomb. Prefab. Now that we just saved call this bomb right here. And from here, we should actually be able to start dropping bombs. So if we go back to our player script here Yeah, we have our drop bomb right now. We haven't actually killed in any values for this yet. So here what we're gonna do, we're going to check if time that time is greater than the player brain donna to next bomb time. And if the player brain active bombs don't count is less than the max active bombs. So that's under player brain Max. Active bombs don't value. Then we're going to drop a bomb. So from here, where we're gonna dio we're gonna set it to game object on Stan. She ate, and we're gonna understand she ate a bomb prefab. So that's under player brain dot bomb Pretty bad. Then where we're going to put this is we're actually gonna want to insurance that the bombs are, um, you know, for Now, let's just go ahead and, uh, set these two transformed a position and the falsetto turning in identity. So we're just gonna actually set these bombs to drop wherein the players standing for now. And then we will just this as we move along as well to make him actually lock directly into the middle of squares as we move forward. So we'll set the player brain the next bomb time people to time that time plus player brain . Wrong placement delay. So let's actually go ahead and test this now to make sure that he's actually activate themselves now and actually, uh, are set to explode. So let's go back into you need here. Don't double check. We've got a player with a player brain on a bone. It's good to see this play. Let's go ahead and hit our bomb placement key and we should see a bomb drop here. But until we actually get stuck on the bottom ourselves here. So one of the things we're gonna actually want to do IHS, adjust this toe where we don't physically get stuck on our bombs. So to do that, Reagan actually go back to our bomb prefab here. It's good re enable it. And for the mess here, we're just gonna change this to be a trigger. We don't actually want this to be a physical collider. We just wanted to actually be trigger Collider or so that way. You know something, hitting it, But it's not gonna actually interfere with players movement, so we can actually go ahead and click apply here, which will make this apply to the prefab that we already have saved. If you look here, there's updated itself, and then you can go and just disable the one on the scene again. Let's go ahead and save it and hit play. And from here now, when we drop the bomb, it's not actually going to stop us. And after about three seconds, we should see it disappear. This way we can drop bombs and a so you can see they're not being placed directly on the squares are now. But we can't address that right now, so they're not showing any particle fix yet. But let's go ahead and hit you, Suppan, and let's actually make another script here. We'll put it under helpers. We're gonna make a new script here called you tills. So this is where we're gonna be using to will store some various formulas that will that will basically be using, um, often. So let's go ahead and open the script up here. So what we're actually gonna want to do is we're gonna want to make this a static class because this is gonna be using We're gonna be using this to do various math functions. Just Teoh make it easier on us instead of having to re type this multiple times through on a project. So we're gonna make a new public static into here, call this round two, take for Hef and then we're just going to return a math F doc Round two ends. We were just passing this float value here, and let's actually make a couple more while we're at it. So over here, let's actually make a later on. We're gonna want to have a couple random variables, so I'm gonna make a new public static int random, even pass in a minute value and then a max exclusive value. So this is gonna be a value that is the upper limit, but it's going to be set in a way where the value itself can actually reach that upper limit. So so get value equal to random range. Well, said it between the minimum and Max Exclusive plus one. And then we'll do. Well, the value is, um well, the value the model of the values itself is not equal to zero. Then we're going to keep basically resetting the value until we have a even value. So they were going to set the value equal to run in the range men Max Exclusive plus one. So this will, um, reroll a value if it didn't roll on something, even just tell it to return the value at this point, we can actually copy paste this year, and we're gonna change is to be a random odd. I was forced to random on value, and we're gonna basically check to see if it is even at this point. So if it's divisible by two and leaves no remainder, then we're gonna keep rolling until it doesn't that we notes on a number and then we're gonna return that. So let's go ahead and save this. Now, let's go back to our bomb placement here, and what we're gonna do is we're actually gonna instead of just setting this to the position of the player, we're actually going to set this to the rounded position for the player, so it's going to force it to be to the center of the squares on our grid. So we're gonna set this to a new doctor. Three. We're gonna set this to the u tills dot around to it. We're gonna set the This is gonna be the X values. Transform that position X and then a you tills around to end transformed defender Why? And then you tills around 2 a.m. transformed a position dot c. Well, let's go ahead and save this here. One more closing bracket on new Victor three. Here I will say this. And then Now let's go ahead and go back into unity on just it. So should take a second date. I'm going to play now when we're dropping our bombs. Even if we're standing between two lines, you'll see the bombs were actually gonna drop in the center of squares every time. Okay, now that we have our bomb created were actually going to go ahead and create the managers that are going to be involved in ensuring that the bomb can properly function and killed Blair. So, first script, we're going to go ahead and make. We're gonna make a game manager script here. So go ahead and make a game manager script and open up visual studio. Once this is open, we're going to add a few things to the game manager here. First, we're going to make a reference to the player brains of each player. So we're gonna make it player brain women, this player, one public player, brain. It will make this player too. Then we're are also going to end up making reference to a state manager, which is a script we haven't created yet or a class we haven't created yet. Rather, So we're gonna make a state manager, will name this state manager here. So the state managers what's going to be used to ensure that all of the objects in the scene will have Ah, a reference to the game manager, even though the game manager will live in two separate scenes. So this will allow us to change scenes without actually losing any of the references to, um, the other player and game objects So let's go ahead and go back in the unity here and let's create our CCRB script here. Roll call the state manager and let's go ahead and open up the state manager here as well. So the state manager of first thing we're gonna want to do we're actually going to change is to be a script herbal object. And then right above this, we're gonna add a create asset menu above this So it will show up in the asset menu so we can actually create a reference of this. That's going to be an asset that will actually attached to our other proof pre fabs and components within the scene. So we're going to make a reference to a game manager here. We'll just call this game manager in the room here. Also, we should actually create our to go ahead and go back in unity. What's making another script here? And we'll call this e names. And here is where we're actually going to store the references to all of our new Merval's so in for this project, we're only gonna have a couple. We're gonna have a public e newme game mode, and this will be how we can determine whether or not we're in single player multiplayer mode. So we're gonna make single player and multi player. And then we're also going to make another one for Game State, and this will store the various, um, game states that the game can be in. So we're gonna have pre game and then we'll have players ready, game active and game over so players ready will be triggered when the game status currently in pregame and once both players have actually readied up. At that point, it will move and actually activate the game. So I didn't save this for now. Go ahead and go back to the state manager and we're going to make a reference to the game State and Game Oats. We're gonna make a public game state. We call this current game state and we'll set this equal Teoh pregame by default and they will make the public game mode and we'll set it to current game mode. Um and we'll set it to multiplayer by default. Perfect. And we could go and save this for now and go back into our game manager now where we can actually have this reference to the state manager properly filled in and from here, we can actually make our references to the game mode as well. So we'll make a public game mode and we'll call this game man, and this will be what we can actually set for the game manager within each scene. Um, so when we add this to the scene, we can actually set the game mode and that the game manager itself will be what notifies the state manager of what game mode were actually in. So all right, so now that we actually have our scripts created, we actually need to add a few different tags by default. There is already a player tag, but the additional ones we need to add we're gonna need to add one for a breakable block. This will be used to, um, reference when we actually hit one of the blocks that is going to be breakable, and then we want to add another one as well for enemy. That way we can determine if a bomb is actually hitting an enemy, so we can tell you the score properly from there. So from here, if we actually go back and to our player here and will change the tag to be player. We can actually go ahead and save this, and then we can begin to actually add the functionality for the bomb itself. So we go ahead and go back to our farm script. We're actually going to be updating the on Explosion um, functionality at this point from here again, we can actually add our statement entering Game Manager now as well. So let's go ahead and make a public game manager. So this two game manager in a public state manager, that's it. This two state manager, lower case s keep it consistent. And then from here we actually want to be doing is we will set the game manager will be set off of the state manager dot game manager. So what this is going to do is, um because the game manager is going to be seen dependent, and the state manager is not the all the bomb. Pre fabs can always have a reference to the state manager to basically just a static object that it's gonna be using to get the other references for what else is alive in the scene or whatever else that needs to communicate with without having to go through the, um, unities, um, search function throughout all the game objects within the scene just because that's a little bit slower. All right. So the logic behind the bomb and how we're gonna be handling the explosion for it is because the bomb itself is actually, um, landing directly on the square. We actually only need to check in four different directions to determine if it is actually , um, hitting something. And for our sake, we actually want the line to only go out two squares. Um so what, we're actually gonna dio we can actually do a, um we're gonna do a loop here, so we're gonna do for int I equals zero. I is less than four, I plus plus. So this is gonna look through four times. We're gonna set the forward rotation on the bomb to be the direction that we want the rate to be going out in. So we're gonna do Transformed out rotation is equal to attorney in Euller brings that this zero and then 90 times I and zero. What this is going to dio is ensure that the bomb itself is going to shoot the ray in one direction and then turn and shoot it in the next, the next and the next until it checks all for, um, directions that it could possibly be hitting something. So from here, we can actually do it a debug on this as well. So we do a debug drawl, Ray. We can do a transformed up position and then transformed up forward because we're always gonna be looking towards the direction we're actively looking for right now will do to F So that's just gonna basically shoot it to units forward and we'll just leave. This is green and we'll set it. Teoh, um, last for 60 seconds for now doing. Go and save this and then we can actually do from here because we can do in. If physics dot recast, we're going to do transfer form, position and then transformed up forward. So the trance, the way that Ray cast works, it's gonna fire from the position of the object itself. Um, and then you choose the direction it goes, and then you are actually in a distance. You actually wanted to check towards the end, so we want it to, um, output to a hit. We're gonna do out hit here. So we need to actually make reference to get up here so we could do a great cast hit hit appear it doesn't need to be referenced. Appear cause in each loop, it's going to actually set hit itself at that point. And then what we can do is said it out to hit, and then we're gonna set the distance again to be to and then we can actually have it check here so we can do another debug here as well, just to make sure it's sitting. Things begin, but I hit and they will put a plus hit transformed that name. So this will let us know if it actually hit an object and we'll know, Take it in the console. And then from here, we can actually handle the logic of what we wanted to do, depending on what it actually hit. So we can do. And if hit transformed, a tag equals player. So this is a bomb hitting a player. They never gonna do a game manager dot on player killed, and then ah, well, actually grab the brain from the player that was it. So we'll do a hit transformed. Get components. Well, dio player dot player brain. So this will let the game manager know which player was actually hit. So it knows which player lost the game. So then we can do in else. If hit that transformed a tag equals breakable block, then we'll just have it destroyed. The block and these blocks will have, um, functionality that will be determined on, um, when it's destroyed, just like the other blocks. So the scene knows that there's no longer a block there, and then they can do and else if hit that transformed a tag equals enemy, then destroy it transformed a tag no, sorry hit that transformed our game object. So let's go ahead and go back into our They're seen here. Let's go back to game manager. We're actually gonna make this on layer killed. Um, I think for now, so devoid. Uh, public life wanted on clear filled. And then we'll take any player brain. That's what's being passed over here. So this scene and then, um, we're going to basically check if the player killed hopes that this two player killed here , they're killed so if the player killed, it's equal to player one, then we're going, Teoh said. This to be sorry. If the player killed is not equal to Player one, then we're just going to say that. Let's just do like this actually equals player one. Put layer two wins from here. We could actually handle the functionality for Player two. Were you doing Else? If clear killed equals player, too? Then we'll do a debug dot log player. One wins later on woman we actually add in the components for the U I as well as the um, score. Then at this point, it will actually be activating in updating the score as well. So let's go ahead and believe this for now. We'll just do this basic things for now, just so we can see to make sure that the players actually dying when we actually hit him with the bomb so we can go back and save this Go back to our bomb as well. And let's actually go to back into the game now and let's see if this is working. Actually, first thing we do need to actually take the game manager here. We actually want us to occur in the awake. Um, method. So this is gonna occur before anything else was in the scene. We're going to set the game manager on both players. So we're gonna set the player won that game manager? No, You need to actually make reference to this on the player now. So let's add the team manager here for the state manager, rather under the player brain. So, Claire brain? No, a player brain. We need to actually add reference to the game manager here to begin. Excuse Put this down to the bottom. Um, actually, no, but it's a dump. The public team manager. So be the game manager here. So we use this again to set reference to that. So player one dot game manager equals, uh, this and the most set this as well. For a player to player to game manager equals this, and then we are going to have it. Um, just make sure these are set here in case we need actually reference those later. So from here, the bomb itself is pulling the game manager from the state manager. So again, when we go back into our game here, let's make sure we don't forget. Actually, under variables here, you can actually go ahead and right click. We're gonna create the state manager. You can just call this statement of your here, and then we're going to create our game manager and put it in the scene as well. So we're going to create a new, um, empty object here. We can just call this game miniter. I think game manager and all, we're going to do it too. Attached to this is gonna actually be attached the game manager script to it. So, um, for this again, we can make reference to the state manager and then to the player to brain for player, too. And the player one brain for player one. So now that we save these, the balm prefab itself does have the bomb script on it. Let's go ahead and add the game manner or the state manager rather to the bomb prefab here . This way. The balm manager itself, Um, or the state manager rather, um is there so that when the bomb looks for the game manager, it can get it from the state manager itself. So let's go ahead and save this now. and if we actually go out and play, we should be able to drop a bomb and have it actually kill us. So for getting a bomb key should be able to stand next to it. And under the console, it should hit us and let's see what we forgot to set. So object reference is not set to an instance of an object. Let's see what this says. So one player killed. It looks like the player itself is missing the player brain. So let's go back to the player or the player brain. It does not have a reference to the game manager, so go back to the game player manager here. And it looks like for some reason, it didn't get reference to the game manager. So let's go back and figure out what exactly happened here. So the tight mismatch let's go back. Look, player bring itself has the game manager. And the player itself has its own player. Brain. Uh, I think I see what happened here. The game manager itself. We didn't actually set it to, um let the state manager No, that, um, this is the game manager for the scene. So back in our a week seen here, actually to do state manager Game manager equals this as well. So we need to let state Manager know that, um, this is the game manager so that the other things can actually reference it. So we go back into our seen here. Now you go back to our console, should be able to move down again. Could our bomb key stand next to our bomb and it should blow up. And there we go. So it hit. It's gonna show that hit the wall and do nothing. And it the player, which then notifies the, um, game Manager that the player has been killed, which gives a win to player, too. All right, so now that we know that the bomb works, let's go ahead and begin to add the particle system for it. That's gonna handle the effect, as it, um is as the timer is going down on it, as well as handling the explosion once it does end up actually exploding. So we're actually going to add a new um, let's go ahead and create an empty object that's going to go on the child of this, and we're gonna just called this particle. And then from here, we're actually gonna add a particle system to this. So for the particle system for this first bomb, what we're gonna want to dio we can actually open up the That's not so the first thing we're gonna want to do. Um, we know our timer is gonna be three seconds. We're just gonna set the duration on this to three. We're actually gonna be editing this within, um, the system later the selection be going. What are based off of whatever your bomb explosion triggered time, miss, And then we're gonna go ahead and turn looping off. Well, let's actually leave it on. What? We're actually building the, uh, particle itself. We're going to set the lifetime to three. Then we're gonna set the speed to zero and what we're actually gonna be doing with this or the way that we're actually going to be having this, um, effect work is we're actually just gonna be having a smaller circle that is in the center that is actually going to fill itself up. I m so as I was describing earlier, the bomb is going to go from transparent to opaque and it's going to, um, caused the bomb toe look like it's getting full right before it explodes. So from here, let's leave the start color simulation, speed and everything that's can all stay. And we're actually gonna change the emission. We're just going to set this to be zero for a rate over time and then under bursts, were actually going to just have it do one burst, uh, one particle here. So it's just gonna go one time for one cycle of one first in the shape. We're just gonna go ahead and change the shape here to be a box. And we're gonna change the scale on this to be 0.1 and we're gonna make it go on the edge. So what this is gonna end up doing is gonna make it do 11 effect like this is you can see one particle is actually just going to be, um, popping up directly on the object itself because of the way that we're actually the way. We're actually using the particle system. We just want the, um, the one particle do not actually go anywhere or move anywhere. And we just wanted to sit still. So we're also going to do here is we're going, Teoh, Let's go down to the render and let's actually outer material for this. So this is, uh, not looking all magenta honest with no material. So it's actually got a material here, and we're going to go ahead and right click, and we're gonna create material, and we're gonna call this bomb. Um, bomb material player one. No, we actually made one of this. Ah, that was the block. Okay, so we have our bomb materials here and will make this a explosion material here to make one more Create material bomb explosion material bomb explosion, Material player One has a little bit wordy, but and then for this, we're actually going to have this be opaque instead of transparent. And then we're just gonna change this to roughly the color we want, which is gonna be a green over here. So we're just gonna go ahead and save this here now. And if we go back to our particle down at the bottom under render, we can go ahead. And, um, just this here. We're gonna change the render mode to be a mesh, and we're gonna change the mesh to just be a sphere, The same defense, fear that we're using for the for the object itself right now or for the bomb. And then we're just gonna set the material to be the bomb explosion material. And when we click play, we should see it's gonna immediately fill itself in. Okay, so now that we know that the particle system itself is actually going to make the fill the entire area of the bomb, we actually want to adjust this down 2.8 for all the scale because of that's the same skills are bomb. So that way, now it's actually matching in size instead of being too large. And then what we're actually gonna want to do is we want to set this to be a size over a lifetime, and we can probably already leave it as the default as it is right now. Says we can see it starts to get full, and it's gonna move it a consistent speed. Andi, it's going to start to fill itself in as the bomb gets closer to exploding. And then once it fills up, it's actually going to explode so we can actually do is well, is we can actually set the, um We can actually create some secondary particles for this as well. And we're gonna actually create these. And these are actually gonna be the, um, the particles that are gonna be handling the explosion. So if we create a new particle here underneath the main one, we can go ahead and create a new empty. We'll just call this explosion particles make this again. Another particle system here we're going to do for this particle system is we are going to said this would change the duration to just be one, And there's not gonna We'll set the delay on it to be equal to three so that since it's gonna be the length of our actual, um, of our actual timer here will set the lifetime to be 0.4, and we're gonna set the speed. We're gonna want this to be random between two constants, and we're gonna set it to be anywhere between 1 to 6. So because of the way that we want the explosion to go, we're gonna want some of the particles to fly further out in one direction than the others . So we're gonna change this between one and six, we're gonna want to start size to be 0.25 and then for the start, rotation will just set it to 50 and the start color. Let's make it a pretty explosion. One cheer. And then for this, let's go ahead and go down. We're going again. Change the emission. We only want this. The rate over time to be zero. And we wanted to just have one burst at the very beginning of when it gets activated and we'll set that to be 100. And it's just gonna still be one cycle. And then for the shape we wanted to just be a box. We're gonna want it to go from the volume of the box. And we want the scale on the X to be 0.7 in the scale on the Y and Z to be 0.1 So and we see this year, we should see the secondary explosion play after the main one, and we can go ahead and stop this here. Andi, What we want to do now is we are going to adjust this to have a color over the lifetime of the explosion, and we can actually just use this default one that's already built in the unity This yellow to red the go ahead and click play on this now is probably still gonna be probable because 5. 2-4 UI Setup: Hello, everyone. Welcome back. Today we are going to go about introducing the U elements for our came as well as adding the second player so that we can actually have a full working two player game. First things first, we are going to add a canvas to the game, which is what is going to be used to actually display all of the elements. So we go ahead and go down here to the hierarchy. We're gonna go in great au I. The first thing we're gonna want to do is we're actually just going to create a U I text and then under the text here, let's see, right. It's actually increased the game view because it sounds a little more helpful when it comes to, um, setting up the text that we're trying to see. So first things first, let's go ahead and set ups. Um, some. You I, uh Here, let's go ahead and sit. This one. This is just gonna be the, uh, timer label. Go ahead and center this one up here. Let's go ahead and change the transform here. If you go and click on this, you can see there's a few different options here to decide where on the, um, where you want to pin the article two. So we're gonna go ahead and pin it to the top center, and then we're from here. We can zero out the exposition and that will send her up the text. We also want to do the same thing where we center. The text down here is Well, it's good to make this about 30. Instead, let's change the height on this toe 1 60 in the width. We can leave it. 1 16 would do this. Name this timer here. You can actually make this all capitals here. That's actually position. Move it up. Um, if we could meet beginning drag or just to negative 100 or so, we're probably gonna want to end up, um, moving this Possibly So let's go ahead and see. Yeah, let's actually position. It's a little bit higher here. Um, it's actually move this up slightly to about It's negative. 85 or so. Ok, perfect. Then what we can do? We can change the color of the texts were actually just gonna make this white, and then we're gonna give it a black border. So the way we're going to do the border is we're actually going to use an outline. Use outline. Here. We can add an outline to it, enter and then we're going to set the distance toe to and negative, too. Well, just make it a little bit bigger. Um, and then for the canvas itself, what's actually just the scaling on this and what's, um, you know, we don't need to adjust anything right now. This is actually fine, because when it's actually closer to full screen, the timer won't take is much of the space on the screen. So this is gonna be the label for the timer. And then let's actually make a couple other labels. If we actually copy this one over this one, we can get it to be, um, score player. One. We can do score P one. Let's go ahead and position. Let's move this over on the X, and then we can change this to just a score and what we can do or you know what? Let's actually just make the state P one. This is will be easy, and then we'll set this to be the color of the player itself. for the text. So, player one, we're gonna make them green where you can set him to whatever color you actually have your player One set to. And then here we can move. This, uh, doesn't need to be a spar over an even lower it all the way down to something negative. 65. Negative. 70. So better then let's, uh, go ahead and copy this over. And this would be score player, too. And the text will be player two. For our sake. Let's go ahead and make player to read. You know, that might be hard for the those were some color blind issues, but we'll just leave it like that for now. If you, um if you want, you can change these two different colors. You can just set him to whichever colors you are going to be using for the light color for the players, Um, as well. So just make sure that it's set up in a way where the people that are playing the game, we're going to be able to tell the difference between the two. So, um, let's go ahead and center this text up as well. You can actually move this text around if we want, um, if you want to adjust it, we're gonna just the sizing on these as well. It might be worthwhile if we are going to use a different kind of score here for the timer . Let's actually lower this down. And for the sake of ah, we can actually make these both smaller as well. Slower. The saw its eyes on these to about 18. This way we can take all three of these kind of shrinking moving down a little bit, and then we'll actually, uh, make a new one up top that justice score. So we take this timer label, we'll just call this the store label. Well, let's get this to say score up here. We can actually position this above the timer and make this one a bit bigger. So it's actually make this to be about 25 and then the timer label. We can even make a bit smaller here. Let's just this town to get 12 words should work. So we're trying to get this in a way to where the, uh the u I is gonna be easy to raid. It looks like this gonna be about 60 and negative. 60 or so. Perfect. Okay, so as we make this a bit bigger, um, that should show up. Perfect goes And then the next thing we're gonna do is we're actually gonna add the, um, measurements for these. So now that we have labels for our score and for the timer, we're actually going to make the next three ones that are actually gonna be used to actually handle the countdown for these. So let's go ahead and take the time or label here much. Just copy this and we'll call this the timer countdown. Let's lower this below this here, it's actually make the timer countdown in the score for both players a uniform size. So we're gonna make this one to be zero here or to 30 Rather make a position. This here about negative 20 or so? Maybe even closer. We can probably get this close for the timer here. Negative 1 15 actually looks like negative 1 17 about right. And then Same thing for the scores for the player one and player two. Let's lower these action here. Get them lined up with the timer here, and then let's go ahead and copied this score. Player One change. It's fun. Size to 30. Lower it down. I just said it a zero. For now, we're gonna want to match it to the same that we have for the timer countdown, which is negative. 1 17 So this is going to be the player One score counter. Then we're gonna take the I'm actually just copied the score counter here, and we will change this to be the player to store. Score counter. Go ahead. And just this year, rename this properly. Then again, change the color. You know, just to make sure you're using the exact same red, let's actually just copied the score player to here and was named this the player to score counter Gansas. This zero negative 1 17 and change the size too early. Okay, for these scores up here, we can actually just the outline on these two A little bit smaller, because the font is a little bit smaller, so it doesn't need to be using his large oven up outline on it. One and negative one. Perfect. Right. And then what we're actually gonna want to be doing IHS No, the timer countdown. We do actually want to still be a too negative too. So what we're actually gonna won't be doing now is the scores are actually going to be using the float Text center script that we have. So, player, one score, we're gonna use this float to text center and the text is going to be the text that's right here on this. And then the variable is going to be the player. One score. We're gonna check this box for always update, and then we're going to do the same thing for the player to score counter again. Look to tech center should automatically be selected by default, and then the variable is gonna be the player to score on. This will also be set to auto update. Then let's actually make a new float variable. Here. We're gonna name this one. The round timer. This will be used Teoh for the timer. Countdown. Rather, I guess it's account up. Either we leave it the name of the same. We're not gonna change that. No, we're going to go ahead at the text for the timer countdown and for the variable. We're gonna set it to the round timer and this one will also be sent to always update. And then let's actually add a new label here that is going to pop up and we'll call this the, um I guess we'll make a new U I text. You know what? Let's just copy. One timer wants the timer or the score label. Here we go. God with score label will name this one. The, um I guess. Ah, Game status. Um, text. Well, actually change this one to be centered again. And this one, we can actually just get it to say for now. We'll say, ready up. And then, um, press bomb key could begin. Let's change the width on this to, uh, something bigger. Believe in height and, like, 200 or so, change the size on the text to make really big players can see it. 50. 50 works. Right? Then the outline probably needs to be a little bit bigger because Texas a little bit bigger . Three Negative. Three. That looks better. Perfect. Okay, so the game status text from here if we actually go back to our game manager script from here is where we'll actually be implementing the you. I stuff that we've actually put in so far. So for the game manager, we're going to make reference to the, um to the, uh will make public wrecked transform. And this will be the games that is text. And this will be used to actually put up the ready text whenever there is a whenever the game is reset and it's waiting for inputs from both players in order to, uh, trigger the game to start. So from here, we can actually go down. And we can set this to actually be updating the status based off of what? It seems so for the state manager, we are actually going to want to be checking if both players are ready when we start the scene or when we start the game. So let's, um, add a new thing here to the player. So if you go to the, um, player brain itself, we have our ready variable. And what we're gonna want to actually dio is we want to under the player itself, where we're actually checking for inputs. Um, don't Here we want to be doing is checking to see if the game mode is going to be, um, we're going to check if the state manager you don't have a reference to statement of you. So it's actually at this right now. So is that a new public state manager state man in her here, we're gonna want to dio is because we're gonna be using the bomb key as both the ready key for the player, as well as placing the bomb within the game. At this point, it's where we're actually gonna be taking advantage of the game states that we made prior. So what we're gonna do here, we're going to check if the player at the bomb key and if they did, then we are going to check the state manager and see what the current game state is. And if it's a game state that game active, then we wanted to drop a bomb else if it's not game active. Um, if the state manager dot current game state equals game, state up pregame, then we want the player brain not ready to become true. And then we want the light Teoh, um, to be set to true as well. So, uh, the player late player likes the game attracted, Said active. True. Okay, so What we can do is basically make it to where when the player actually readies up is what's actually going to activate the light for them. So that's one way that we can actually see that the player is in fact ready. So if we so from here what we can do is actually go back to the game manager. Now that the player can actually set themselves is ready, we will go back to the game manager, and we're going to make a new function down here. Just called, um, pool players and ready. We're going to use this to check to see if both players are ready. So, um, we're gonna do. And if player one, um is, um, ready, Um, and there is no player to player game object, then return True. So this is gonna be for single player. This is basically if there's no player to yet and player one is ready, then it's going to start the scene. Um, else if player one is ready, Layer one is ready and Player two is ready and we're going to return true as well. And if neither there's a truth and we're going to return false so because we're using return, return will always exit the method immediately. So we don't have to worry about any of the code underneath actually getting triggered. We can even remove this else here because if the 1st 1 is true, then it's not gonna get down to here anyways. For readability sake, we can even separate them. So it just makes it a little bit easier to read through if someone's looking through it. And then from here, we can actually, um, set a timer here. So let's go back. And during our update frame here, we're going to do a, um if the state manager dot current game state equals game state, the pregame and the players are ready and players ready. So by adding this players ready here in this, um, in this if statement, this is actually gonna run this method, which is Gandhi gonna check if the players are ready and it will return to riff also right in the right here in this if statement. So if both players already, then it's going to change the state manager dot Current game state equal to game state players ready. And then from here. Sorry. Just one equals here and then from here. What we're actually gonna want to dio is we want to actually have a, um, countdown tick here so that the players have ample time to know that the game is about to start. So let's add a couple things up here real fast. What's at a public text? Um so in order to add a text, we need to add you at a new using directive up tops we're gonna use using unity ngen dot You are, And then that will give us access to text. And we will call this the countdown timer text. And then let's, um, also give ourselves access to the Let's make a countdown timer and we'll set it equal to 33 seconds is a good count down time. We'll do float next, count down, tick this 20 And then we can also add in a audio sound for the tick. So let's make a public audio clip, uh, countdown tick, and then a public audio clip countdown. And so this way the players kind of have a countdown timer that's gonna dio and then it will start. We can actually, just at an audio clip in here for music as well if we want to have background music in the game. So what we can do is three Septus now. So let's go ahead and save this and let's go back and we will set the when both players are actually gonna be ready. We're actually going to set the next countdown tick to the equal to time dot time plus one , and then we are going to change the ready up the game status text rather so games that is text. I'm not game object that set active. We're gonna set that to false. So at this point, once the players are ready, we're gonna get rid of the text that says to ready up. And then we also want to play our first countdown ticket this point. So we're gonna set the audio source audio. We didn't have an audio source yet. Section put the right about the audio clips here, public audio source, audio source here and at this point will set the audio source dot play one shot and then the count down tick and then we're going to adjust. The countdown timer will set it. Text equals to the countdown timer. Plus, um, a blank here. So what this is actually going to do is, um, countdown timer texts, text. So what this does is because if you can't just pass Justin Inter into the countdown timer And instead of converting the integer to a string, we can also just do plus a blink, um, section here and that effectively turns it into a string as well. Then from here, um, we will go into the next if statement, which will be else if the state manager the current game states is equal to game state players ready then at this point is where it's actually going to check to see if the if time that time is greater than the next countdown tick. Then it's going to trigger countdown counting down Tick, actually making new method for this year. It's actually just go ahead and put this revolution septet method here. Floyd, Countdown, tick. So what we can do here? We're gonna take the countdown timer. We're gonna minus minus its We're gonna subtracted by one second. And then if the countdown timer is equal to zero, then we're going to play the audio source dot play one shot play one shocked countdown end and then we're going to set the state manager, But our current game state equal to game state game active. So at this point, it's going to activate the game. So then players will actually be able to start dropping bombs from here. Will take the count down text timer, text of texting will just set it to nothing. And then if we we want to have, um we're actually going to need to have any value here to for the round start time we're gonna want existed this float round start time will use this for the timer. Um, that we have on our screen center there. So Saint changed around start time. We'll set the round start time equal to time that time. So this is how we're actually gonna determine how many How many seconds there, actually on the timer itself. And OK, then we have the round start time there. If we are gonna have music and are seen, we can do if, um music. So if we have music, then we're going to do an audio source dot clip and we're going to set it to music and then we're going to do an audio source dot loop people is true changes here, Luke. People's true than audio sourced play. This will make this actually play the music in the background. And then, uh, else So we're out. We're done. This is what we're gonna do. The countdown timer. Zero. If the countdown timer is not, then we're gonna set the countdown timer text dot text equal to countdown timer plus blank . And then we're gonna set the audio source, not play one shots on. We're gonna play the countdown tick when we go ahead and save. That's here. So right now we want to do here is we need to actually set this to where the everything will reset if we need it to reset. So let us reset the game here. So on start, what we actually wanted to do is every single time on the beginning of the scene, we're going to take the state manager, and we're gonna set the current game state equal to game states pregame, and we're going Teoh set the round timer. We actually didn't added a reference to the round timer yet, so that's actually at that now. So the public. Let's make a public vote variable here, ground timer. So let's actually reset the ground timer here. Yes, well, we'll take the round timer value will set it equal to zero. And then we will set the, um, countdown timer equal to three again. And then this should actually reset itself now. So what we can do down here under the state manager? This is where we want to ensure that the players can only actually move when the game is in the proper state. So let's go back to the player script now. And from here, we want to add a new here. New secondary check care where we check if the state manager current game state is equal to game. State game acted because otherwise players would be able to move around before everyone knows ready. And then we also, um, next, you know, that's what we need to do in this one. Then we go back to our game. One of the things we didn't actually make was the countdown timer. So we can actually make the countdown timer here. If we go back to our scene. Let's take the games. That is text here. Go ahead and copy this. Well, just make the C zero. Let's change the font size in this to something really, really big, Like 1 50 something that can't be missed. And we can actually just, um, clear this back out for now, and we'll name this the count down time. Here. Go ahead and save this. All right? Now that we got that cat fed, let's actually get all of our components at it needed here. So on the game manager itself, we had some new things out of here. So we have a game status text that we need to reference. We have a countdown timer texts that we need to reference. We need to add an audio source to our game manager here on a You can write your reference to that as well. And then for the countdown tick, we have these here. Countdown, tick, make reference to a countdown end as well. Countdown final. And for the round timer. We have this done here as well. We already created earlier the music we can leave off for now. If you end up having music you want to add, there isn't included. Clip in there. Right there already. There's a couple of them, a couple different songs you can try out in your game and then I'm actually I'm not gonna leave. I'm gonna leave mine off right now, though, because it makes it harder to listen to me when I'm talking about playing in the background . And then what we're going to want to do is actually lower the volume on this again because the default volume immunity is very, very loud. So we're gonna lower this to about 0.2. Then on the player itself, we added a state manager, a reference to the state manager as well. So we do need to make sure we attach that to our player object. Otherwise, it will give us an error when we start our game. So double check again. You have references to everything that we are referring to on the player itself. Check the player. Brain. We didn't have anything you in there, but let's go ahead and hit play now, and the game should be preventing us from moving until we hit the bomb key. And at that point, we'll see that it's actually starting the countdown. But the countdown timer moved really fast there. So let's see what we made a mistake on. Let's go ahead and go back to our code And let's look at our game manager code here. So what we forgot to do Waas actually increased the next countdown. Tick time when there was actually a, um countdown Tick. So after the countdown take here, we want to actually set the next countdown Ticking will do time that time, plus one. So because we didn't do that, we got ahead of ourselves. But now that we save this forget and go back into our game, you can actually play now again. Again, everything will be locked. We hit the bomb key. When we hear the timer that lets us know that it's ready. And then we can actually start moving. It's from here again. Let's go ahead. And, uh, because the game again. And let's make sure that this timer here is actually ticking up. So if we go back to the game manager here, the last thing we want to check for So this is the 1st 2 games states. Then we're gonna dio check the last game state. So if the state manager, the current game state is equal to game State that, um, game active. Then we want to adjust this to set the round timer that value to be equal to, um, math. I guess we're going to the u tills around event, and we're gonna take the time dot time minus the round start time. So that's going to take the time when players actually readied up and then elections take up the timer from there. And then, um, we can do to do here, we're gonna add a escalation, um, tears. So, ah, if we do actually start the game here, one of the things I've already found out from testing this game is that there needs to be some escalations in progress. Or sometimes the games will go very, very long. So let's go ahead and save this. Make sure that timers working, and then we'll go ahead and add the second player as well. So check this here, make sure that starts. And as we see here, we got a timer ticking up every single second. Then let's go ahead and, um turned the game up here and then let's actually make our second player now. So a couple things were actually gonna want to do is for our bomb Prefab Here. We're actually gonna activate this again. We're gonna name it's two p one bomb now. So this is gonna be the bomb for player one. Let's go ahead and apply this. So it's gonna let's actually just throw it in. Here is a new prefab here. So, player one bomb, let's actually copy this year, it's make a new reference that we're going to call this the player to bomb. So the p to bomb probably enter there. That's not gonna say p to bomb. And for this we're gonna change the player brain to be player two and then the That's all we actually change for that one. What's actually just change this Be to here, throw it up in the corner. Then we need to makes a change. Is here to the player because this player is actually read right now. So if you go back to our player here, we can actually deactivate both these bombs again and are seen Go back to our player wherever they are. City player one If you look at their model right now, they're model is green where? I mean read. Sorry, we can actually adjust this to be it should be a green virgin. That is not actually here. I think we actually going to want to change something in this summer green. Let's go ahead and just this here. Summer green. I think I see what happened here. So, Claire, we actually imported. It's actually set this to the other player. There we go. So if we actually see our player, they've actually updated, and they're now green. We just needed to select the other, um, mesh that we had because the mesh that we imported in is connected to a specific because it's an object file. It's actually connected to a specific, um model, um, or the The material that it's using is connected to the model itself. So by changing this to the proper green model, it actually updates this to green. Then we can actually take the blue or the red players. Well, which is gonna be player two. So we copied this here. We can actually let's move them all the way to the bottom corner here instead, what's changed this to be player two save This will change this to negative for and negative three. Let's go ahead and adjust this to be player two. Brain. The player light will set the light color to the, uh, read instead. Could make this a darker ready something? Actually, no, that's about the best read we're gonna get. So, uh, yeah, that's right. It's good. And then again, let's go back to me clear to itself. And we gotta change this, um, model to the other one. That is red. So there's gonna be the player models. You don't have any feet or anything on them yet, so I can adjust any of this stuff yet, but we're just gonna leave them floating up in the air for now. We're gonna do the animations in a different video. So let's go ahead and save this year. Then for the game manager, we can go back and for the player to brain, we can actually player to script. This is already said to actually update the brain with the player that it has that way. The seen will know whether or not it as one or two players at that point. Then let's actually update this, too. Um, update the score when one of the players actually dies now. So let's go back and under the player killed here we can, because we're gonna be just resetting the scene when the, um when one of the players actually, um ends the game or when one of the players wins will weaken Dio, we can use the countdown timer text we'll set the font size will lower it down to 30. And then we will set the countdown timer text text equal to this will be player two winds with an exclamation point. And then, if we used the backslash end, this is a a line break, and we can do hit bomb key to restart. So that will actually restart the game when the bomb kiis it. And what we can do is at this point we convict the player to dot player scored a value plus plus so we can increase the player to its players for at this point because they've won. And then it's not looking again. Uh, we'll do the other way as well for player to work for player. One rather player, one winds thin, will take the player one score and we really increase that. So, um so this will be if the game state is multi player. Let's just do this now so we don't have to come back to later. If the game mode is equal to game mode multiplayer, that's when we're actually gonna want it. Teoh increase the score for player one and player two. Um, otherwise we want Teoh. Just get it to change the text the same way, But it's just going to say game over, then that will be for single player. And then, for now, we can get We'll get the state manager to set the current game state equal to game state game over and then we'll set player one dot ready equal to false player to dot ready equal to false. Then from here we can do is actually get the game to reset if anyone hits a bomb key after the game has ended. So if we actually go in here and we'll do a last if check here so else. If the state manager dark current game state is equal to Game State game over and um, if either player has hit the bomb key in could not get key player wound up on key or input . Duckett he? Player two dot bunky. Then we're going to do a scene manager, so we're extra gonna need to make a reference to this, Which iss um you're using directives unity engine dot Seen management. That is where the scene manager is. The scene manager is gonna be used to reload. Seems similar to what we're using in our flapping firefly game. We're going to do a scene manager dots seen we're gonna want to load the current seem so we're gonna do seem manager to get active scene and then dot build index and then that will reload. Which ever seen we have. So this same functionality will work on both the single player and multiplayer game modes. So now this is saved. We should be able to go back into our game now and just this out. So one of the other things we do want to dio is for a player to We are going to want them to be using the player to bomb. So under the player to brain, you want to, um, update this to use the other thing. So we need to adjust. This player score means to be set to player to score the max. Active bombs needs to be septum Expected bombs. We want their light color to be read what their movements be to be following the same other player movement. Speed balm. Prefab is going to be the player to bomb, and we're going to need to adjust the color on that before we actually start our game. And the bomb placement delay will be the bomb placement delay. And for these keys, let's actually set them on the arrow keys and the num pat. So, for mine, um, I'm actually gonna send it to this. There should be a up arrow for up way down arrow down here. Left key. If you don't have a 10 keypad on your keyboard, you can set the bomb key for the player to be something else. This is gonna be left pair of. This is the right key I've lost here, right arrow and then the bomb key. I'm just gonna set it to be enter on the num pat for this player because maybe keypad enter , keep, had enter. Go ahead and save this. Let's go back to our bomb here, actually, and we need to adjust some colors, so for a player to bomb. We actually need to make another material here. So we have a bomb material player too, that we want to be transparent as well. And then we are going to make this red. And what did we have? The Alfa Value said two year 60. Okay, we're gonna take this red and regular this out value here to 60 as well to keep things consistent. So we actually make this bomb visible so we can actually see what we're doing as we change it, the mesh itself. We're now going to set it to use this, um, material for player, too. And then we are also gonna want to change the particles on this. So we're gonna need to make a new explosion. Material is well, that copies this one. We're gonna make a new material. Must be bomb explosion at Material player, too. Now, let's just copy this exact same material. So the other one is opaque. This one's gonna be opaque as well, and we're just gonna set the color red. We can save this. Then for the main particle down here, we're going to take the material for the explosion, and it's gonna be read instead of the green. So when we get play, that should now function the same way as the green one did accept it will be read instead beginning it. Stop now on this, the rest of the bomb effects are the same. We can actually just hit apply on this to make sure this gets saved as the player to bomb prefab. And then we can go ahead and hide this again. Mayor ago hadn't saved our scene. And at this point, let's go ahead and test to see if we do actually want to change your game out here to multi player. Since this is gonna be for the multiplayer scene. So it's actually go and press play here. Uh, even after ready upon one character and ready on the other, you know, let's change. So for the players themselves that's actually set their lights to be disabled at first, since that's something we want to only be enabled when the player is actually ready so we can actually see that. So we get play here again, get the ready key one that IHS not actually selecting the Clear Lakes. No, I didn't that activate. Let's go back to our script here and figure out what we forgot to do here. I think under the player we did, um, we did not do this properly. For some reason, the player light game object is not actually activating itself. So let's figure out what we're doing wrong here. So the lights we had Okay, I see what we did. Now that I think about it, we actually disabled the room. Think so. Instead of having the light on here we want to Dio is, um we can actually change this to B. Um, we don't actually want to disable it where we don't want to enable it this way. We want to actually go back to our scripts here and instead of a game object outset active , we want to do a player object, uh, enabled. And we'll set that to true equals. True, Never go. So because we're actually disabling it and we're not actually activating or dissent deactivating a game object. We want to use the enabled. So this should now, when we enable it will turn on the lights for both players. And then from here, one player can drop a bomb. I'm gonna blow myself up. Which again? Because player one is the woman died. We'll see the countdown there or the score. Rather went up for player, too. And then as soon as we hit a bomb key, the game will reset. And then from here again, we're gonna hit play on both. And it looks like we just ran into a bug with the unity editor in regards to how it handles the light. So let's go ahead and save this year, you notice to get some weird artifact there with light. So let's actually go back and figure out why that IHS let's go into our lighting here on check if we have anything we want to be doing here, and you should probably set this to No, - I believe if we actually unchecked this auto generate with lighting that should actually fix it here so we can actually talk to generate here. Then let's actually put it to the test here. Well, let it real of the scene, even if that is something occurring. The editor. That's not something that should be occurring in game. Let's put it to the test here. There we go. So now that we turned off the auto generate on the lighting. The editor will actually handle the resetting of the light. They're properly because otherwise it wasn't getting loaded. So that's actually gonna be it for this episode. And the next one, we are going to start implementing the ah, anim 6. 2-5 Animations: however, one. Welcome back today, we're going to learn about using the animation system within unity as well as set up the starting animations for our characters. So first thing we're gonna want to do, we're going to go ahead and want to select our player one, um, component here and that's good. And make the scene view larger here. So, in regards to animating this character, we're actually going toe want to, and we're gonna want to move the renderers so the mesh filter and the mess surrender to a a child object underneath the subjects. Let's go ahead and create empty here, and we'll just call this body and we're going to go ahead and add a mess, surrender and then a mesh filter. And then let's just go and take the default mesh we have here. Let's actually delete the one off of the main came object here so we can go and remove these components from the 1st 1 the render as well. And then for the 2nd 1 we got the render in here. But now we need to make sure we add the material itself, which should just be under palate. One of these will be for the Red Player. One of these will be for the green. Make sure you select the one for the Green Player. All right, so now that we have the correct palette selected as well with So when we go to select the mass, you need to make sure we actually select the one under the bomber green here. If we select the one under Bomber Red, it's gonna, um, be the red character instead because both of these characters were using the exact same palate. Um, it is connected to the actual mesh itself. So let's go ahead. It's like the bomber green here, and then we're going to actually make We can actually go ahead and copy this components of you to sit control D and we'll call this one. Um, could this, um, bomber? Let's call this left hand and then what we're gonna do here, we're actually going to make a new object here. Let's go ahead and take this. And instead of this default here, Rex going to make this the default here, it's one that's called default, which was called Bomber Foot. And it should already it uses the same meshes the palette here. So we're actually gonna put this here and let's actually place it on left where it's supposed to be. So go ahead and mix and match and decide where we want this to actually be on. The players are on the object itself. We'll just leave it here about 0.25 and negative 0.3. Um, looks pretty good for now. And then let's go ahead and control D on this, and we'll name this one right hand. We're gonna put this in place, so this will probably want to be at 0.3 if we're going to keep things symmetrical here. Actually, it looks like the unit itself. Ah, yeah, That's well, this hand looks a little bit closer here, so let's move it over here a little bit. Maybe coat 0.35 Yeah, it looks bettering. All right. And then we can actually just copy both thes select them both by holding shift, and it control d when we can actually move these down here and we'll call this left foot and right foot. And then let's go ahead and move these in a bit as well, because we're gonna want the feet to be a little bit closer to player as well as inwards. More so let's go and get thes lined up underneath. Here. Let's decide. These can probably be it. Exactly. Um not quite sure what it's called Negative 0.1 and negative 0.1 and then they're positioning will be put to and it's negative. Ah, negative 0.15 Firstly, it actually looks about right. So now that we actually have these objects created, what we're going to do is actually go ahead and begin animating it. So let's go ahead and hit control us here. Let's go ahead and get this saved before we begin animating it. Though I did notice a few things that we are gonna wanna want to change here is because of the way that we're going to be animating the player itself. We're actually gonna need to make some adjustments to these extra objects that we actually have here. So first thing we're actually gonna want to dio is we're gonna actually want to go ahead and move all of this down so that we can get this lined up with the floor. But we're actually gonna be aiming here and for the hand and foot objects themselves. The way they were actually going to be animating them is we're actually gonna be affecting the rotation of them. So by just moving the rotation between negative 60 and 60 you'll see that the box itself is actually just kind of rotating here. But it's just staying in place. But if we actually create new empty game objects here, we'll call this one year. We'll call this left foot, left foot, I guess. Left hip, then go This. So this left hip, we can actually even just lower this a little bit. Here, let's make this negative. 25 So it's about where the hip is and what we can do is we're gonna take this left foot and actually, we're just gonna drag the left foot. Work is gonna attach it here to the left hip. So now when we actually rotate the left hip, you'll actually see that the foot itself has actually suede outwards instead of just staying in place because it's rotating again from the hip, and anything on the end of it is actually being rotated out with it. It's actually land this back up to zero, and we just got to do this exact same thing, but we got to make a another one here, so we're going to duplicate this. Delete the other foot from it, will call this right hit, and then let's actually create a new one as well for the hands. But let's just go ahead and let's duplicate this. Before we attach anything to it, we'll call this right hand and we'll move this backup. Teoh, I guess, zero for the route for where we're doing the hands from and then duplicate this again and we'll call this left hand. And again if we actually just drag this right foot onto the right hip. I guess this would be right shoulder. Let's call this right shoulder. Keep things lined up here, right shoulder and the left shoulder. So to the right shoulder, we're gonna attach the right hand into the left shoulder. We're going to attach to the left hand, so if we actually go back onto this now rotate the left shoulder will actually see that the actual arm of the player is returning with it. So now we can get some Bob its way there. All right, let's go ahead and set piece back to zero, and now let's actually go ahead and begin to animate. It's the first thing we're going to do here. We're actually just going to again. We're gonna set the samples here to seven. That's going to ensure that its seven frames per second is what the animation speed's gonna be. Doesn't need to be very high for what we're doing. And then during this zero frame here, we're going to go ahead and create a key frame here. Let's go ahead and click at property, and we're actually going to be adding the left hip. We're going to go ahead and go to transform and rotation, and then we're going to do the same thing for the right hip and right in left shoulders. So let's go ahead and at the right hip here, transform rotation and we're gonna add the right shoulder transform rotation and the left shoulder transform rotation. So here we go ahead and click. This will go ahead and add a key frame here at the beginning, and we're gonna go ahead and move to frames forward. So what we can do with the animation tool within unity is we can actually basically let it blend our animations for us automatically. So if we move to frames forward and we select the second frame here, all the changes we make will be reflected here in the second frame. So from here, we can go ahead and click on the left hip. So when we select this second frame in the left hip, we can go ahead and go to the position here and we'll just change the X here to 60. We're gonna be having the player take a full step backwards here and for the left shoulder . Here, it's going to be doing the opposite. So when the foot is going back in the hand is going forward to counter act. That motion doesn't need to be doing it quite as much. So if the Foot is going 60 than for the hand, it's good. Make it like a negative 40 here, and then we'll do the same thing for the right hip. Let's make this negative 60. And for the right shoulder, we can make this 40. So if we click this and make sure we go ahead and click key frame here toe, lock it in, we can actually do here is See that we forgot to keep reminiscing before made. The change is so let's select the key frame here. Cook on the left hip again. Set this to 60. Then the shoulder is going to negative 40. The right hip is going to negative. 60 on the right shoulder is gonna go to 40. So now these air selected should be able to get this to save. Here we go. Uh, key frame. OK, now the key frame is set. Now, we should be able to actually go in here and said Thies Sorry, this is give me some issues here. Let's make sure we get enter. So we're saving these. Think that might have been my issue here. Negative 40 right? Hip is going to negative. 60 on the right shoulder is going to 40. Okay, now, if we go ahead and select this, um, left shoulder 60 Uh, negative. 40. Love tip. 60. Right hip. Hang in there. 60. All right, shoulder 40. Okay, that was my issue. I forgot to have the recording on. So something to keep in mind when we're actually moving forward to record for a key frame? What we want to do is we want to, um, make sure that we check this box to enable key frame recording. So as we move forward here, you'll see now that we have the set, this is actually going to as it goes through two frames, it will go to that. And then it's just gonna loop again. So if we just sit this little play button here, we can actually see what we have so far, which is just the first step here and school and save this here. It's actually move forward to frames and basically what we're gonna wanna have it do again , we're gonna enable keeping recording again. We're gonna move forward two frames, go ahead and hit this button here to add a key frame, and we're gonna want to make sure we had a key frame for everything. So make sure you select all four of the components because we're gonna want to add it. All of them during the key frame and we're actually going to be doing for all of them is actually resetting them back to zero for this frame. So if you look here again, we want they're gonna have them begin walking with their right foot forward, and then they're gonna go back and even back out, And then what? We're gonna actually have them? Dio is during frame six. Go ahead and add a key for him here. And then we're going to do the opposite of what we did on frame to so one for him, too. We had the, um, left foot going back. So for the frame six, we're gonna have the left hip going forward now, So this is gonna be the negative 60 and then the left shoulder will be 40 right hip. I will be 60 and the right shoulder will be negative. 40. No, this is saved in the North Sea. Back at the last frame again. It even itself. Back out here, um, back at center. But we're actually not gonna want that to occur there. We're gonna want this to occur. One frame forward. So because the, um, this is where the animation will be resetting. So we actually need to make sure this is evenly spaced out. And then let's go ahead and hit play. Now we can see that the animation loops without any delay in it. All So for just actually looking at the player character there. We can actually see that they are moving about without any issues. So from here, we can go ahead and on play this year. And no, this is actually saved into the animation of the player itself. So what we can dio is we can actually take this player here and move them back to where they're supposed to be, which is 45 And from here is we're actually gonna want to go into the animator itself, and we're actually going to add some conditions. So we're gonna want to have and I'd oppose where nothing is going on and then something that actually goes into the run animation cause we don't want them to actually be doing anything if there is nothing else going on. So we're actually going to go into this animator tab here. We're going to go out and right click, and we're going to create a new state called Empty. And here we can go ahead and in this new state player Idol. So what we're gonna want to do here is we're actually gonna want the entry here. So this is going to be the default states of your right click and go to set his layer default state here. This is going to be the default state that the player goes into as soon as they are entering the scene and then or actually want to do is we're gonna actually get what, here under parameters. And we're actually gonna add a new parameter that we're gonna just have it be a pool. We're just gonna call this moving so this will basically be triggered whenever the player is actually moving. We're gonna enable this so that the, um, animator will know that it's to go from being in the idle animation to the actual moving animation. So believe this parameter here and from here back under the layers go ahead and under player idol, we can go ahead and click here where it says make transition and we're just gonna draw street to the player animation and then from the player animation we're going to right click, and we're gonna make a transition as well. That goes back. So now that we have these transitions made, if you actually click where it says player idol again and if you click over here on the transition under the inspector, you will see it will actually have a drop down here. And what we're gonna want to dio is under conditions here. We're going to go and click this plus here, and we're gonna make sure that the condition is moving is set to true. So whenever moving is set to true, it is going to move into the player animation, um, which we can actually rename this to, um, run animation here. So whenever the player is begins moving, then we'll start playing the run animation. And then once from the run animation, when we actually wanted to go back to the Idol state, we are actually going to want it to, um, go back whenever moving is set to false. So when moving, is that the false? It's actually going to go back, and we can actually have it have a bit more of an exit time if we want, um, what's actually increase the, um, exit time by a bit. So let's change it to, like point at nine. That way, it, um, doesn't end abruptly here. We'll let it ensure that it's actually finishing the animation almost entirely before it stops so that you're not seeing legs snapping around and then were you don't really have to change it. And from here, we can save this. So all these changes that we actually made here are actually getting saved to the animator here. This one, this is player one controller. We're gonna be able to use the same controller for the animations. Um, for both of the players. So we're not gonna have to worry about that. What we can actually do here is now that we have Player one, we can actually go ahead and duplicate this on. We're gonna make a new player to here. Has to be player two down here when we're actually just going to copy this. Where's the other player to aunt? Name this player. Too old for now, because we're gonna copy some components off of it. So we got negative for in three for a negative three. We get our new player to here. I got an old player to let's go to move him out of the way for a second. Now we copy other stuff over So under the player to we're going again. We're gonna want to, um change things on it. We want to change the brain to play or two. We want a cheek. Sure, the state manager will be the same player to light. It's gonna be the same. But we're gonna change the light color, appear to read, and then animation driller will stay the same and under the player to and actually is everything is actually connected to the brain. So we don't actually have to change much. Other than the main body palette. We're gonna want to ensure that it is set to go. We can actually delete this other player. Now it's credit. Like the old player now under the body. We're gonna want to make sure that they are set to the red player. So if we actually select, um, the, um, mash filter here and we actually select the other player filter, you'll actually see that it pops up here and now we have our second player. They again have the same animations as player one. So they both have their walking animation now. And now that we actually have the animation created, this is where we go about adding it in as could All right, So, in order to get this added in its code. Now what? We're actually gonna want to do Rex and go ahead and go and edit the player script now and under the player script, we are going to do this to do at Animator here. We're gonna go and replaces of Public Animator Animator. So we're gonna make reference to the actual animator that is attached to the player itself . And what we're gonna want to dio is in the update frame. The first thing we're always going to be doing is we're going to be resetting the animator or the movement, the movement, rather in case the player stopped moving. So at this point, we can do animator dot set bull and we're gonna set the bull moving. We're gonna set this to false. So if you're trying to, um, these set bowl or set int um, methods that you can call that are attached to the animator You can use this to actually modify any of the parameters that are on your animation system. So for this one, it's very simple. It's only gonna have the one parameter which is moving, and we're going to set it the false at the beginning. And then what we're gonna do is if the player is actually moving at all in any of these other ones, it can actually go ahead and paste this down here and we're gonna actually set moving to true. Well, that's good. Set this to true and save this and let's go and copy this true one. So if the player actually puts down any input key and they are moving and what we're gonna want to dio is, we're just gonna set moving to true. So no, it's good. Just paste this All in here to set the player is moving. And that is all we actually need to dio in order to actually have player movement in here. Now it's no Go ahead, make sure you save this. Go back into unity and let's go ahead and give it a test. Would make this whole screen again. Should we hit play on both players? Remember what we had for a bomb keys here. We actually didn't set something here. The very let him out. We did not set the animator for both players. So go ahead and select the animator here for player too. And then on the player. One object as well. Make sure we set the animator for a player one and go ahead and save thes. Both received Seen Rather. And now let's go ahead and play. Uh, one players ready. Here we go. All right. No, for actually moving around. You'll actually see that the player will stop. And the second we move around, we'll actually see their little arms and legs moving around here. Andi. Then when we start moving this start moving, I regale. That's actually, And this year, there we go. OK, so now that we have our first animation in place, that's gonna be it for this lesson. And the next one, we will go about making the, um, escalation phases toe where, as the time goes on, further, the game will get progressively harder, basically, to try to force the game to end. Um, so it just doesn't turn into a very long stalemate. So we're going to do that by actually adding in bombs that will randomly spawn around the terrain and around the world. See you in the next one 7. 2-6 Boomberman Multiplayer: everyone. Welcome back In our last lesson, we had just finished up the animations for players. And in today's lesson, we are going to introduced the escalation tears into our multiplayer That way. Um, as the game starts to go on longer, there will be various things that will pop up. There will be just extra neutral bombs that will pop up that will actually be blowing up the players or extra things for the players to have Teoh worry about. So first thing we're gonna want to dio as we make this is Rex, you're gonna need to make another material so that the neutral bombs will have their own color here. So we're gonna make a new new ah material here. So right, click. I'm going to go to create material. I'm going to create this a, um, bomb material neutral. And then for this, we can go and use any color we want. I'm gonna go ahead and use a, um we're gonna make this one transparent, and I'm gonna just go ahead and pick like a dark purple. You can use any color you want here. Let's just make this easier. What is this? Nick should make it a little bit brighter. Believe it. Just a bright purple appear in the corner here. Then let's go ahead and do the same thing here. Then we're gonna also make another material. So this the 1st 1 is going to be transparent, and then we're gonna want it to be opaque for the color of the material that's actually going to be filling up the bomb so that you can actually see roughly when it's going to explode. So we're gonna go ahead and create another material here, and we can just call this bomb explosion material neutral, and then this one is gonna be a Pake, and we're gonna go ahead and select that same purple color we want here. We can actually make sure that these were the same color if we want. But if you just click on the color and you can select the hex color and just control C and copy it, you can just go ahead and paste it over on. The other one is so make sure you get the same color, and then this one we can go ahead and save this, and we're going to go ahead and take one of these other bombs that we have over here that we already have created. Go ahead and just duplicate it. And we're going to rename this to neutral bomb, and then we're gonna remove the brain that's attached to it so that it's not connected to any specific player. And then we are going to go under the, um, mesh for it. And we're actually going to adjust this to be the material that we just created. And then we're gonna also look under the main particle and ensure that we under the render here we're going to change the explosion material toothy new explosion material we made as well. So go ahead and save these, then that. So we need to do here. Then we're gonna go and take this neutral bomb, and we're gonna drag and drop it into our pre fabs so that we have it saved here and that it can so that we can spawn it. So what, we're actually going to you want to dio is in order to make the game a little bit more, um, varied. So every game isn't just exactly the same what we're going to do. In addition, to the bombs randomly spawning. Once the game gets escalated it we're actually going to have a breakable block that we set in motion prior. And we're gonna go ahead and create that right now as well. So if we go ahead and create a new material, Aziz Well, here for the we have our Bach material, we're gonna make a new one here that it's going to be a breakable block material. So right, click create. Gonna go and create a material will call this breakable block material for this one. We're gonna want this one to be transparent, and then we're just going to select a color close to whatever we have for other blocks so that they will, um, it'll be pretty clear that you can actually break them, or we're gonna lower the Alfa on these even more to to just make them a bit more transparent. So once we have this den Rex, we're gonna go ahead and take our block that we have here one of these blocks that we have in place. Let's go ahead and duplicate this. Rename this to breakable block, and then let's go ahead and slide this over so we can see what it looks like here. Well, disposition exactly negative for four. And then for the material, we're gonna change it from block material to the breakable block material. So you can see here it will have a different look, and it is transparent. So it makes it more obvious to the players that it can actually be broken. And then what we're gonna want to do here is we're going to attach a script to it on, and we're actually gonna have to make that script. So now that we have a breakable block, let's go ahead and save. This is a prefab here. Let's go ahead and throw it up under brief halves and let's make a new script. So we're going to create a new script here. I'm gonna call the script Block. This is going to allow us to that's good. And get this open up here. This is gonna allow us to Dio is, um allow us to handle the breakable locks, and we're actually gonna want a block manager here that actually will know which blocks we have and which blocks we don't. So it's good and create another script as well we'll call this a block manager, and then we'll go ahead and open this one up as well. So for the block manager, this is what is actually going to be keeping track of what blocks we actually have spawned and what blocks we don't have spawned. So at the beginning of the game, we're going to want it to randomly spawn blocks. Um, throughout the map, Um, in order to keep things simplified to make sure that we don't block in the player, we're actually going to just make sure that it will spawn Onley in these center for blocks here that we see. So we're not gonna have any spot on the outside and cheer because we don't want to have a scenario where the player actually gets box did and can't actually move from their spawn point. So let's go ahead and go back to our block manager here. We're going to do, we're gonna make a public list of block, and we're going to call this active blocks by default. Weaken said it to equal to a new list so it could be empty. We're gonna make a new public, came object here, and we're gonna call this block prefab, and that's gonna be our breakable block. I guess we could name that breakable block. Prefab, breakable block, prefab. There we go. And then what we are going to I want to do here is we're gonna add a new public dictionary , Call Inspector three, and then block. We're going to use this to active blocks dictionary so that we can, um, we'll set this eagle to in a dictionary. So when you see me type in your dictionary again, if you have tab, it will auto fill based off of the, um, based off of the class that's already defined, um, under the variable here. So and then we can This is where we're gonna actually set our minimum and maximum block, um, values here. So if we make a public sector two max block, I'll set this equal to a new vector three. And I believe let's look at where our blocks their spawning. So if this block right here is negative three negative four, we're gonna want to ensure that the maximum that it could be is going to be three and negative two, and the maximum that it could be is negative three and four. So Vick should go back to our blocks here that Max Bach is going to be 34 and in the public sector, too. Men block. I was going to be in New Vector three. Well, said this to negative three. Negative, too. If you end up adjusting the size of your arena or things like that, this is where you can actually go in and adjust these. And then we're actually going to, um, make a couple of of methods here that are actually going to be called by the blocks themselves when the blocks are either spawning or D spawning. So we're going to do, we're gonna do a public void here, and it's gonna be set active luck. We're gonna set the block block and the vector three position. So as we're actually spawning these blocks, when the blocks are actually spawned, they're gonna notify the block manager so that it knows where blocks are currently at. And then that way these congee referenced, um to, um ensure that it knows where blocks are, so it's not trying to spawn more on top of the others. So it's going to be important that we know where blocks currently are, so that when we're actually spawning blocks randomly were not spawning more than one block on top of each other. So we are going to for setting an active block we're going to do. And if the active block dictionary, um, if it doesn't contain, um, this position, then we're gonna go ahead and add it to the dictionary here, going out block here. No, we're going to, um, under the active blocks, we're gonna add it. And then under the act of blocks dictionary, we're goingto added as well the position in the block. And then we're going to do the same thing for removed block. We're gonna make a new public void removed block buck, take the block on the position, and this is where we're actually going to check it. Thea active locks dictionary already has the block. And if it does, um, then we're going to remove it at this point. So well did active blocks removed this block and then active blocks dictionary dot Remove the position so that we know that that block it actually gone. At that point, we can go ahead and save this now under the block itself. A new block is only going to have a couple methods here. We're gonna do a new reference to the block manager. So to the block manager here and then all we're gonna do is we're gonna make a private Boyd awake. So as soon as this block is actually spawned than it's going to, um, it's going to tell the block manager exactly where it is and exactly what it is so that it's gonna do the transformed up position. And this is gonna be a soon as the object is awake. So that's going to, um, be as soon as it basically wakes up and we're gonna do a public void on destroy here and then when the block is actually destroyed, that's when we're going to have it. Send the event over two. The block manager toe, let it know that it's actually been removed. So let's go ahead and save this now. And from here is where we can actually make use of this on the game manager here at the start of the game. We can actually have it do. Here is we can actually make a new method. Well, that's good. Minimize these for now. And let's actually make a way down here and we will call this sponsoring the blocks. Look, Boyd, this doesn't actually to be public Private Boyd Sponder in the blocks, and then we're going to do the float, which will be the count, and that will be passed in two having me, however many we want to spawn. So by writing it this way, if we wanted to add this to the escalation tears or something similar, then we could actually have it check for, um it could we could have it spawned blocks as well as bombs at other times. So you may run into scenarios or players or getting trapped or all of a sudden they can't move somewhere anymore. So that might be an interesting adjustment we could make to the game later. So what we're gonna want to do here is, um let's go ahead and make a reference appear to the block manager as well. So, under the state manager is going to a new public block manager, this will be called the block manager here and for the start method is where we're actually going to have this, um spawned random blocks. So do a. So it starts and then we'll do a sponsor and the blocks and then we'll do a randomized block counts. And and let's just make this year a new public float here. Let's go ahead and do this public float, um, starting randomised blocks. We'll just set this, Teoh. Let's go ahead and send it to, like, eat starting randomised blocks. And then we'll do that here, starting a randomized box. So that's gonna be the number we actually pass over here to how many blocks were spawning and then the let's go ahead and, um, start this up. So the first thing we want to do, we're gonna want to check to make sure that the block manager, um, actually has a block prefab a breakable block, prefab them. If it doesn't have one, we're just gonna return. So that means basically, if we don't actually want to spot any, we'll just make sure that's not set, and then what we're gonna do, we're gonna do a loop going to do for anti equals zero. And as long as I is less than the account of blocks were trying to spawn, I want to just go ahead and spawned blocks here. So from here, we're gonna do We're going to actually be looping through a a bunch of different positions that are actually on the arena itself. And any time you have, um, something that is going to be using a while loop where it's going to be, keep flipping through until the conditions are met. You want to actually set a limit on that? Because if there is some error in the code or for some reason there's no available positions for something to be spawned, then you could end up in an infinite loop that will end up crashing your game or into crashing the system. So we're gonna do a bull, um, blocks bond, and this is what's actually gonna be used to get out of the while loop that we're going to set up. We're just going to into attempts on grounds that this is zero. So we're gonna want to dio we're gonna do a while. Uh, the block is not spawned. Then we're actually going to have it cycle through the, um, possible spawn points. So let's, um, go ahead and check a few things here, so the x value is going to be equal to a random dot range between the we're gonna want the block manager dot um, men block dot Exe and the block manager max block dot Exe. And I guess we can do the, um, and here and sure that these air actually quantified a sense. So by forcing these as integer values, we know they're gonna be inter values. Um, we can actually just ensure that this is going to, um, reference them is intra values as well. And they were going to the same thing for the Z value. So the random dot range has to be ent block manager dot um, men block dots. Um, why? Because it's a vector to so vector to it's always gonna be an X and y value. And then we're going to do the int again. Block manager max block dot Why you and save this year? So we're actually going to have to make another method here that's going to check if the physician is actually open. Um, for two placing about block. So we're actually gonna make a new, um, value here in reaction to do a full position is open. We're gonna check the Vector three position. We're going to use this to actually check of the position of either other blocks or the player or other bombs were going to use this, Uh, when we're doing our escalations as well to check if the position that we're trying to spawn the escalation bomb at is actually open or if there's something already there. So the first thing we're gonna check we're gonna check if the Block manager Dr Active Blocks Dictionary contains the key or contains this position. If it does, then we're going to return false. Well, I wouldn't say that. And then we're gonna do another if and we're actually gonna check for the player one dot player game object. Um, if this player exists and the position equals the position of the player, what we're gonna, um, want to do is ensure we can't spawn anything there. So because the the player itself can actually move around and they're not always going to be directly, um, on the center of a block or exactly a whole value position we're actually gonna want to do , we're going to make another method here as well. That is going to round out the players position the same way that we're rounding out the position when we're placing the bomb. So, um, if you look before when we're actually, um, spawning are bombs, We are actually, um, rounding these as well. So what we're gonna do here is we're just gonna take the same thing and we're gonna make a new vector three. We'll call this rounded vector three. We'll take in the vector three dot position. And for this, we are going to take the, um, Vector three grounded V three. It's going to be equal to a new vector three here, and we're gonna take the u tills dot round to end. We're going to pass in the position dot Exe and you tills around to end. Um, position that why you tells around to end position, Don't see. Go and save this and we're going to return this rounded V three here. That's always going to give us the direct centrepoint. Basically, we're always going to be taking an entered value for where we're trying to place the object . So we're going to check that position against that specifically as well. So this is going to be the rounded Vector three of the player one dot player game object that transformed a position. And then, um So first we're checking to make sure the player actually exists. Um, and then we're also checking if the, um if there's something actually on that spot, and if there is, we're going to return false, and then we're going to do one. Maura's well for player to we got again. Make sure the player to extra exists, because in single player mode, Player two will not exist, and the position is equal to around a director. Three player, too. That player game object transformed a position, nor can return false here. And then what we can dio if it passes all those checks weaken dio a return. True. So the reason why we don't have to to use an else if here we could, um, it doesn't really matter either way, because it will never actually get to these other if statements, if it anticipating one of the first ones because we know if it's blocked by any object, then we can go ahead. Move on. We don't need to keep checking for more objects to see if there's anything else in that position. So now that we have this, um, we're going to verify here. So, um, if the position is open, we're going to check the, um well, you know, we can actually make a new victor three here. The vector three position equals new Vector three. And that's going to be equal to the X zero and the sea, because zero is, um, where we have all the object spawning on the exact, um, zero point on the Y axis. And then here, we're gonna do. If position is open the position, then, um, we are going to, um, spawn a new block here. So we're gonna do blocks. Pond is gonna be equal to true. And then we're going to do a game object in Stan. She ate the block manager, a breakable block prefab, and we're gonna spawn it at the position, and we're going to do a coup attorney and that identity so that it maintains theme rotation that's already on the object. And then the other thing we're gonna do is, um, Also check. We're gonna do if he attempts are greater than 50 number. Just gonna say that the block is spawned. Eyes equal to true that way. 50 is more than it should ever take to find a neck and actual open position. But it's a number that's still low enough that it's not gonna lock up the game if it's test to cycle through all the loops. But also, um, high enough that it will not end up missing a spawn unless there is just really bad, Um, orangey, I guess where it keeps electing a position where there's something already there. Um, Then we're gonna at the end of this well loop, we're gonna increase. We're gonna increment the attempts so that to make sure we don't end up getting locked out , Um, well, it's stuck in a while. Loop here. So, um, while loops, they are useful in situations like this where you are relying on, um, on random number, generation to do spawns for objects. But again, you need to ensure it is the best practice to ensure that you have, um, something in place as a backup. Just in case. For some reason, the numbers are just rolling in a way toe where it could cause the system to lock up. So let's now this is actually in place. This is actually done, so these blocks could be spawned. Here we have our block script. So let's actually go back to our game now. Andi, let's go ahead and test this to see if these were actually working here. Okay, so it's good and go back to our game. We have our new breakable block here, and let's go and add the block script to it. And let's make reference to the block manager. Let's actually create the block manager over here. Well, actually, add the block manager as a new, um script or serialize herbal and, um, object so that we can actually just spawn one. So if you go to the block winter here, we're actually gonna make this a script Herbal object, so it will persist outside of the scene. I will do a great asset menu here. Go ahead and save this, Andi. But go ahead and make your reference to this year. So under the variables, we can right click, and we're gonna go ahead and create a new block. Manager just called this block, match your hair and we have our blocks here and under the breakable blocks. Prefab, Let's go ahead and finish making reference to the block manager here. And then let's go ahead and save this. We actually click. Apply, then this will apply all the settings that we the changes we already made to this to the, um these will actually all be applied to the prefab it we have over here already. So we're actually gonna change the tag on this too? We need to change this to be a breakable block. So let's go ahead and change it here on the object itself, actually get apply so it gets saved. And then now that we have this breakable block here, reconnect should go ahead and remove this from the scene because we don't actually want that on there. We have it saved under the prefab with the breakable block. The block script is on it. It has three breakable block materials on now under the, um, block manager, wherever that just went top. Let's make reference to this breakable block. You see, there won't be any active blocks yet, but now let's go back to our game manager as well. And we're gonna make sure we reference the block manager. Go and save this thestreet ing randomized block counts is gonna be eight, so it may actually load the scene. Um, it should automatically be spawning these blocks. Unless we messed something up. Let's go and give a shot. You see, here eight blocks are responding, but it looks like it didn't. Actually, um, it looks like it managed to spawn on a spot that already has another block so that it's because these other blocks are not properly tagged yet. So let's actually ensure that we get the block script on all of these as well. So let's go ahead and select all of our primary blocks here, and we're going to go ahead and add the block script to them, and we're gonna have the block add them to the block manager as well, so that when we start the scene, um, these are going to be again. Um, it's going to trigger it in the awake method it's going to set. This is an active block so that the, um, block manager knows that there is already a block on this spot. And then again, the awake method happens before he start method. So we know that during, um, awake, it's gonna call the awake method. It's going to add all these to the dictionary first, and then when we go to have it spawned the other random blocks, those air now going to speak to not be able to spawn in positions where the other blocks were already at. So now that we have that going, well, go ahead and say this here. And we should actually make a reference to this first, um, main block here that's going out at the pre fabs. In case you want to have non breakable blocks that are spawning within the world. That's something you can also do if you want to take this idea even further. And now that we have the blocks in place, let's actually go and test and make sure we can actually blow them up. So I don't think we've actually added that could And yet, so let's go back in to our bomb code here, and what we actually do have it set. So we already have. If it it's a breakable block, then it's going to destroy that object again, are breakable. Blocks already have that. So let's go ahead and check it here on and let's go ahead and drop a bomb here. Let's see the bulls of the book, and it does so again, we're making sure that it's blowing up the proper bombs here, but it's not gonna blow up anything else and get perfect. All right, so let's go and double check. It's gonna hit the 1st 1 and it's knocking a second. Perfect. So let's go ahead and back out of this. Now what we can also add in is Theis escalation tears that we want to work on before. So let's go ahead and open the game manager back up. And over here is we can actually add in a, um, variable for an escalations. So what we can have it do is as the game progresses onwards, we can actually have it, um, progressively get harder and harder. So we're gonna go ahead and we're going to create a new very Bollier. A new foot variable will call this escalation tear, and this is going to be start at, um, a certain value. Whatever we wanted to be. Let's go ahead and start it at, um, let's just go. It started at one. And that way. Um, what it's going to do is during the first escalation tear. It's going, Teoh, um, spawned one bomb. And then during the next one, it's gonna spawned two and three and, um, on earth, a non word. So now that we have reference to this, let's go back to our game manager here. Let's go ahead and make any little block here for escalations. So we're gonna make a new public float variable. That's gonna be the escalation tear. Then we are going to wanted to also have an escalation. Start time will make a public float escalation start time. We can go and start this at either 10 seconds or 15 seconds school and started a 11th. And then we'll do a public float escalation frequency, and we'll set this to five seconds. And then let's go ahead and make a new public game object here, and this will be the neutral bomb. This is gonna be the bomb that we have that's actually going to spawn, and then the we're also going to have to make reference to a, um, float around start time. Sorry about that. I forgot. We actually already have the round start time, the round start time will be more of something that actually comes up during a single player because the scene isn't gonna be really reloading as you go further and further own on the rounds. But for single player or for multi player, it's always because it's reloading the scene every single time. The round start time will always reset itself. But for this, let's go ahead. And we're also gonna have a, um have they float here where it's going to trigger the next escalation tick. So it's going to do that and it's gonna have a value set for that. So here in the update frame is where we're actually gonna add these escalations that we actually have now. So under the escalations is we are going to have this. Um, it has this round timer value, and what we're gonna do is we're going to check if the round time or value around timer value. It's greater than brown timer. That value. If this is greater than the next X escalation tick and we're gonna have it triggered. An escalation trigger escalation on Let's go and make the method for this now and then, um, we can also dio Let's go ahead and put in the stuff already for a single player. So we're gonna do it else if the game mode equals, um, game mode, that single player. And ah, you know what? Actually, let's sign of that right now. Hold will come back to that. So this would be to do single player escalation. Check That way, we remember to come back to that. And now, under trigger escalations, let's go ahead and, um, do our loops for checking for objects and placing them. So first thing we're gonna do the same thing is before we're going to do a, um for And I equals zero eyes less than the escalation tear value. We're gonna increment by one each time throughout the loop before we get too far on a place . Let's ensure that we are actually resetting the value of the escalation tear at the beginning of a scene before we forget. So we'll take the escalation, tear that value, and we'll set it toe one so that every time we reload the scene, the escalation tears ensuring that it actually re resetting itself, and we're gonna set the next escalation tick equal to the escalation start time that it's going to, um, spawn itself at exactly the start. Time is where it's gonna have the first tier of escalation. So down here we have. We made a reference to system here, so let's actually make sure that we're using the, um, unity engine that random here because we made reference to that. So let's make sure that the unity engine dot random here as well, because they have a reference to system up above. Let's go ahead. And you know what? We can actually get rid of this and just get rid of the reference to system instead. So that's just gear that we don't need to be using. System up here. Go and see that and again, escalation to your value set escalation tickets that now under the trigger escalations. We're gonna go ahead and want to dio we're going to do similar to what we were doing before , except this one is going to have changed depending on if it's multiplayer single player. So let's go ahead and do an If game mode equals multi player our game mode dot multiplayer , then we're going to do one thing. Um, else it's the game mode equals single player. Then we're gonna do something else. Civility to dio single player escalations. So this is where we're gonna have it spawned extra enemies or start the next wave? Um, basically. So for the multi player, we're going again, we're gonna check if the bomb has been spawned. Believe it, it false. This is pretty much gonna be the exact same code that we're using for the, um, for the Sponder and blocks except are actually going to be adjusting it slightly. So if we actually want to copy this, um, we can use this is the reference. So if the bombs found it's false, we're gonna set the attempts equal to zero again. And then while the bomb is not spawned, what we're gonna dio we're gonna do the into X equals a random dot range, except this time, these air going to actually be able to spawn, um, anywhere that the map itself contains. So, um, because of where the map is positioned, we know our max, um are our minimum maximum values that we can actually spawn at for the X and Z excess are negative for five, and then the see value is going to be a random. That range. That's gonna be negative. Three and six. So before this this way, they can spawn anywhere within the map itself. Um, regardless of, um, as opposed to the blocks themselves, you can actually walk through the bombs so we don't have to worry about them actually trapping a player in that sense. And these are actually made to be killing the player. So if they happen to get tracked by a bunch of bombs than so be it. So we'll do a new vector. Three position is equal to a new vector three here in ex zero and the again Then we're gonna do again. This is where we're gonna check. If the position is open the position, then we're gonna do a bombs. Bond equals true. And they were going to spawn a game object. I haven't, Stan. She ate. We're going to spawn a neutral bomb at this position, and we're going to leave the rotation the same. And then we're gonna do again. Same thing again if he attempts are greater than 50. Done bombs, Bond. It was true. And then attempts were going to continue to increment This, um perfect. Um So now what we should be able to dio was, let's ensure that the, um, this area here again is checking for, um, the block manager. We don't care if there's more than one bomb on the same spot that can actually happen. So, um, let's go ahead and check this here and let's see if things are actually going to escalate. So let's go back to our escalations here, and it's good and save this and let's put it to the test so you can actually do pretty easy test here if we just have the game start was activate both players and to do not have the bomb button it's going on. We didn't make reference to something again, Uh, we forgot to make reference to a neutral bum. So let's go over here. We didn't make reference to the escalation to your or the neutral bomb to get ahead of ourselves here, so we got our neutral bomb as well, and we actually don't want to make a reference to this'll neutral bomb. We actually want to make reference to the, um to our prefab Mitchell bomb. So let's actually remove these non prefab ones here and to make sure we're actually referencing the pre fabs themselves and not the game object from within the scene. Easier way to do this would be to ensure that we are just actually Dragon dropping from the project over here itself. So under the prefab will do this initial bomb here. It's good. Make sure that these other variables aren't referencing these other bombs by chance either . And on their player, too. That has proper promise, will. Okay, so now that this is actually set, we can go ahead and save this and let's go ahead and hit play. It's going ready at both players, and then let's go ahead and wait and 10 seconds we should see a bomb spawning, and at that point, the bomb should spawn and explode. And then it should spawn 2nd 1 from there. So it looks like it spawned a bomb, But all right, this misuse. So let's figure out what's going on here. I think what we did is we actually didn't add any adjustments to the code for the bombs for if it is a neutral bomb. So let's go ahead and go back to our bomb here and let's take a look at her code. So for our bomb here, we're actually going to do um Oh, you know, we actually just forgot to do. We just forgot to actually enable the bomb. So let's go ahead and just make it toward this bomb is actually, um, enabled by default. So, um, let's go back here to a game manager. Um, escalation to value respond equals true. This is going through on and we are responding this and under the bomb itself, let's just go ahead and activate it so that it is, um, enabled by default. And we've got to make sure that we have this saved. So this is enabled because it's not actually being enabled by one of the other objects here . And like, should we do the same thing for the other bombs that's ready up. That wasn't Sica's we When we copied the prefab over, we left it as an inactive bomb. So the bomb itself wasn't actually trying to explode or do anything else. So oh, uh, let's see what we did wrong. So I think what we forgot to Dio is we forgot to set, um, how many bombs that's supposed to actually spawn. So let's check to see where we messed up. So here, under the trigger trigger escalations, it's going to check the, um, escalation tear dot value. And we're gonna want to dio is we actually, after we set this, we actually didn't set a time on when the nest next escalation should actually occur. And we also didn't increment the escalation value. So here, we're gonna do nest next escalation tick. It's going to be, um it's going to be implemented by the escalation frequency. And then we're also going to want to set increment the escalation tear, um ah, by one. So we're gonna increment that by one so that the next time its bonds it's going to spend more than one bomb, and it's also going to ensure that it is only spawning one vomited diamonds that it last thing where the world ended all at once. Now this is done. It's going to save this it play. Once it re compiles on, Let's go ahead and make sure that this one actually spawns properly. This I don't think many players would be having very much fun of this game if it spawned that many bombs every single time. So, yes, I just noticed here that the texture that it is using for the bomb itself appears to be using the material here is needs to be made really transparent. Because it Ah, you just can't tell. So what do we have here? We had 60. All right, let's go into the same thing for the neutral bomb here. You couldn't tell that the bomb or when the bomb was actually going to explode. So it's good and justice to 60 as well. Keep it in line with the other bombs. It's going back out of your changes you make to sh aiders will stick even if it's done during the scene. Let's go ahead and save 8. 2-7 Boomberman Singleplayer: Hello, everyone, welcome back in today's lesson. We're going to go ahead and create the single player game mode and seeing, and we are going to make some adjustments to the bomb code because I noticed that there is a small issue with our initial design in which, if they player is standing directly inside of a bomb because of the way that recasts air handled, he will not actually be hit by the bomb explosion. So let's go ahead and first fix the bomb code, and we will you then, um, use those adjustments and then we'll move on to the single player mode. So first, let's showcase exactly what's going on with the bomb code as it's currently written right now. If we actually were to drop a bomb and not move the player, the bomb, a book, but it won't actually hit the player. And the reason why that why the player won't get hit is because of the way that um, Ray casts air handled when it recast is, um, pushed out. It will not actually hit anything that it's already inside of so because the, um because the colliders for the player object itself are standing directly on top of where the bomb is. If the rate cast is being fired from the center, it's going to ignore anything that it's already inside of, and it's only gonna hit things that are outside of that radius. So we're actually going to do is we're going to do an additional check on the bomb code itself. So if we actually go back to the bomb here, um, we are going to do a another check is well, um, from the bombs position and see if any, um, player is actually under that position. So let's go back to our game manager code here where we had this rounded Vector three that we were using to determine the, um to round out the players position. And let's actually move this over to our util script. So it's actually go ahead and copy this method here. Go ahead and control X to cut it. We're gonna put it under the U tills here, and we're going to actually make a public static director three and we'll put the rounded Vector three in here. We can get rid of this. You tills dot Since we're actually referencing this internally now or in the same class. Go ahead and save this. And under the game manager. Well, do you till start rounded Vector three And we'll just this here and then from here. What we're going to want to dio, um is, um, check to see if a if a player is actually, um, standing on the position of the bomb. So let's actually check that first. Um, So what's do a, um if the if the game manager uh um actually, let's check the u tills dot um rounded vector three. And we're gonna do check get the game manager dot player one. That player game object transformed a position is equal to my own position. So the transformed opposition of the bomb then, um, we're going to do a game manager dot on player killed. Um, and then we're going to do, um, game manager dot player one da player game object that player Brain. Where's that at? Um oh, there we go. Game manager up. Player Player One is the actual reference to the brain itself. And then, um if, um, them also check if the game manager that player to and top player game object so first, we got to make sure player to is there because this exact same functionality is going to exist, whether this is in single player or multiplayer. So when it checked to see if, make sure Player two's in the scene before we try to reference the position of the player to. Because if we try to reference the position a player, too and they're not there, then it's gonna crash the game because of an old reference exception. So that's to hear you tills surrounded. Vector three. We're going to reference the game. Manager it up player, too. Player game objects transformed a position that's a bit long, but okay, So if this is equal to the transformed a position, then we are going to, um, kill player to on player killed game manager dot player, too. All right, And then because of the way that, um, the things are handled under the game manager itself. Um, when the player is actually killed, we are going to. So let's see appear where we got our own player killed functionality. We are going to, um, make sure that the game state or that the game, um, state is actually under game active before we actually kill. So we're not actually implementing the, um, score again like, um, more than once. If somehow the player is considered to be in the position of the bomb and somehow still gets hit by a recast or gets it by more than one bomb, we're gonna do it if the game mode is equal to or sorry, If, um, the state manager, the current game state is equal to game ST dot game active, then we're actually going to check this code because if the, um if the game is, um, already in progress or if the game has already ended because, um, a player has already died, then we don't actually want it to adjust further, though I guess we'd have to decide if we want. Um, actually, no, this is fine. We can actually not put this in there because I realize what will happen if we actually do end up making these changes is that the first player that gets hit will be the one that ends the game in the second player won't be so. That would effectively kill the person who either gets selected randomly, based off of which direction of the bomb there on first. Or it will always kill player run if both player one and player two or under the bomb at the same time, which it should increments the score for both. Um, yes, it shouldn't ah, increment the score for both. So, um, yeah, let's go ahead and leave it like that and see if that way it'll incremental score for both , since it is actually changing how maney, um, kills each player gets. So now that we adjust it this code, let's actually go and test it should be good. Now to make sure that the player drops the bomb inside of themselves, they will, in fact, you killed so dropped a bomb right on top of ourselves, and it's going to end it, so something we can actually do here is Well, if we want to know this Texas bit wonky, let's go ahead and justice here, where the score counter the outlining is a bit weird. One and negative one. No, that's the wrong one. Countdown timer to a negative, too. Yeah, let's just lower this back down to two and negative, too, because it's, um, showing up a bit wide for this example. We are just using the normal text. Um, in our next example, since it is now included in the newer versions of Unity and we will go ahead and time, we will go over using text message pro, um, which has its own built in outlining features. But that one has a bit more advanced stuff to it as well. If you are using unity, I highly encourage taking a look, a text, much pro. It is free now that it has been brought into unity, and you can pretty quickly and easily convert all of your text into text much pro text. Um, but that will be covered in a future video. So now that we know that the bomb functionality is working correctly, let's actually go ahead and, um, make the single player seen. So let's actually go ahead and do a file here, and we're gonna do a safe seen as Let's go under. Scenes must actually go ahead and save this as a single player scene. It's called single player scene. We're going to go ahead and save this here. Okay, then under the lighting here, let's make sure we generate the lighting as well. Um, this doesn't need to be done. This is just going to ensure that it kind of makes the light mats for the blocks that already there. So it's not trying to run those at real time. And that's what where these other folders are being created from. So in this scene, um, now that we're in the single player seen, we can also again If we want to go back to the multiplayer, let's go and save this. We'll see we have multi player in single player scene we're actually gonna want to do is we're going to create a new button here up in the corner to switch between the two. So let's go ahead and change this to, um, we're gonna make a new u I. And we're gonna make a new button and we'll call this seeing swap button or game modes. What button? I guess. Game mode. Swap button. And we'll do, um, can take this us spray. We're gonna just leave the one that's on there. Let's go ahead and change the color on this. It's making something darker and let's then go ahead and adjust the text on our button here Let's make our text Wait. Let's make it a bit bigger here. Let's go ahead and build it on and make it s so this one will go to single player. We can go ahead and give this an outline as well. Good. How fine. One. A negative one. That's fine. And let's go ahead and move this up into the corner. So we're actually gonna just the anchor point on this just to ensure that it's fully anchored up in the corner here. So regardless of this size of the screen, were playing on the position of the button will always stay the same. So if we adjust thes probably gonna want it to be about 100 1101 100 down about 50. Negative 50. That's a bit too far negative. 20 or so should be fine or negative. 30. That way we have the button up in the corner itself. Um, and it will always kind of be out of the way him that way. So if we shrink this down again, um, or adjusted to like a free aspect or change aspect ratio, it's also going to maintain its position. So now we have this button up in the corner. What? We're actually gonna have this button? Dio. Let's go back to our game manager script and here we're gonna have the button swap between the two different game modes that we have. So we'll just make a new game out here. We'll do a public void load single player, and this will just do will call c manager dot load scene. It's gonna look single player scene, and then we're gonna make another one for multiplayer as well. It's a public void load multiplayer. And then let's go ahead and do seem ender. I have seen multi player multi player scene. Here we go. So from the, um, from the multiplayer seen here, we can actually have this game sought mode. Button on Click. It's going to reference the game manager here, So grab the game Manager Dragon. Drop it onto this under own click and then we're gonna do the game manager and we're going to load single player, and that's going to load the single player game mode. And then let's go ahead and save this, all right? And now that we have our single or multiplayer seen here, um, let's go ahead and go to our single player, seen as well. And let's go ahead, make this exact same button. Let's go right click you I But in what's again, We could make this a slightly different color here if we want. It's good to make it even a darker blue, maybe, or even a different color. Make it some sort of green. That's, uh, sure. Let's make it a darker green. Or so what's changes again? Game stop button. We're gonna change the text on this to be a multi player. We're gonna go and build this change the color to White and again select the game would stop button here, the upper left hand corner. We're gonna want a position 100 negative 30. Make sure you adjust the anchor here as well. And then the on click effect is going to be Make sure we select the game manager and this is going to do the game manager load multiplayer. It's the function is gonna do. We're gonna save that. I'm also here in the single player seen Ah, because this is single player. You want to go into the game manager here, change the game mode over to single player and then the player to object. Just go ahead and select them and delete the player to game object and go ahead and save your scene. And then here we're actually gonna want to go up to where it's this file and build settings , and we're going to add this open scene. We're gonna add the single player seen here. And if we dragged the multiplayer scene, we can put it above the single player seen. So when we first put up the game, it's gonna look multi player first. Ah, in order to actually swapped to these scenes using the scene manager that we had reference before under the game manager script, Um, they need to be in the build. So now that they're in the build here, we can save this and we can hit play. And from here, if we actually click multiplayer, we'll see that it does load up the multiplayer scene, and the second player does come back. Then we can again. So it back to single player and it will make the player to go away so we can confirm that's working now. So let's back up. Um, because the single player scene is going to be using, um, only one player, the u I. A top is actually gonna change a bit. So what we can actually do here is we can get rid of where it says, um, score here. So the timer label that can stay this score player one can stay, but we're gonna just the text actually say score. Let's actually change the size on this, Um, a bit. It's actually, um, yeah, let's actually change this year to be, um, smaller. So it's good put the score will make this 15 bold. These the outline can maybe be increased a bit too negative, too. Let's get rid of this other score label up here. Uh, get rid of this one. Let's actually move these up a bit, too. Um, we can line it up toward it. Doesn't need to quite be down that far. So let's make it maybe what is this? Negative 85 And this score player two is now going to be Ah, the wave counter and this is going to say wave began will change it to be the same. Size is the score. I will make this boulders well changed. Outlined 22 and negative, too. Let's actually go ahead and change us again. Negative 85. Just like the other one. And then let's actually take the timer Countdown that it's fine. And the, um, cool down timer is that's the countdown timer here, timer label. We can increase this to 15. Again. Pulled. This is Well, um, the labels already the same negative 85 as well. And we can actually to stick this timer countdown, the player, one score timer and player to score timer. So this one is actually going to be the wave counter now and then, instead of referencing the player to score, this is actually going to reference the escalation here. So because the escalation tear is I'm always going to be starting on it. One begin even filled in with one that first. If we want. Let's actually take this wave one counter, the player, one score and the, um, timer as well. And we can actually, um, select all three of these. And we're gonna actually just bold thes There we go. And let's actually move their Y position to about swears it's negative. 100 should be fine. her effect. Uh, let's go ahead and save this here. And now let's make sure this is all still set properly because these are separated from the game manager themselves. We shouldn't have to make any adjustments in that sense, But under the game manager, we're actually gonna want to have it be referencing, um, enemies. So we're actually gonna need to make another manager here. We're gonna make a new C sharp script, We're gonna make the enemy manager, and we're going to go ahead and make an enemy script as well. So we're gonna create another script. I'm gonna call this enemy. And now let's go into our enemy manager script. And here we should see her enemy manager script. And we're going to make this a script herbal object. And we're gonna make this a create asset menu so that we can actually create one of these. And this is gonna be just are very similar to our block manager. Except it's, um, going to not have ranges for minimum maximum types. And we're also going to set this up to be able to support um, different enemy types if we want to have those. So let's make a public list and we'll call this game object. And these were gonna be enemy types equals a new list of game objects. So this is gonna be pre fabs if we want to have different enemies within the game for single player. If we want some enemies that move faster or of, um, different abilities, this is we're going to set up the basic framework for that for if we want to go ahead and extend it, you know, make a public list of enemies and these were going to be ah, spawned enemies is going to be equal to a new list of enemies here, and we're going to make a couple methods here, which is gonna be public void, that enemy, and that's gonna be enemy enemy. And then we're going to check to make sure that thesis bond enemies, um, doesn't can already contain this enemy here already. And if it doesn't, then we're gonna go ahead and add it. And then we're gonna do another one here for a public Boyd remove enemy and in the enemy. And they were gonna do if it contains this, um, then we are going to removed the enemy. So let's go ahead and get this saved here and go to our enemy script that we created a swell and the enemy script is going to make reference to a few things here. 1st 3 Enemy script is gonna need a reference to the state manager because it's going to need to know what Thedc aren't Game State is. It's gonna want a reference to the enemy manager because it's going toe. Want to, um, it's gonna need to be able to tell the enemy manager when it's ponds and when it dies. And then, um, this is also going to have an animator just like the players. It's going to have a public new, rigid, body, rigid body similar to the players as well, and it's also gonna have its own light. We'll give it a tone light so that it can, um, make reference to itself. I will make it a new light here and then. So the way that we're actually going to be having our enemies, um, basically moving around, we're gonna want to give them a, um, public float for speed. We'll go ahead and said it toe to for starting and then we're going to give him a spawn time as well. So roughly how long the player as to react to the unit itself actually spawning before it's going to start moving. So it'll pop up, and then it will have kind of a delayed time before it actually starts moving, just so that it's not immediately spawning next to player and attacking them right away. So, uh, when we set the float to time to spawn here because these are gonna be spawned at different points during the round, depending on which escalation tear it is or on when it's getting spawned. Um, then we are going Teoh have to add something to reference whether or not the spawn timer has started. Go ahead and set. This too falls for now. And, um, we'll check if the, um enemy is actually ready. So let's go ahead and do a few things, so we're gonna do a void awake. So when the enemy is first spawned into the game, we'll do the enemy. An enemy manager thought at enemy on will make sure this object gets added into the scene here, and then we can do one also as well for a void on destroy and do enemy manager uh, don't remove enemy this so that when this gets destroyed by a bomb, um, it, uh then kills itself. And we are going to want to reference thes state manager Andi or the game manager Rather And we're going Teoh make a new method here for when the enemy itself is actually killed. So let's go ahead and create that now. So under go ahead, make a new script or a new method here other, we'll do a public void on enemy killed. And let's go ahead and put this in here and let's actually have this increment the player one's score when the enemy is actually killed. Player One player scored value plus plus. And then we're gonna have it Do is check. Um, at this point, if the, um if the player has killed all of the, um, all of the units, then what we're actually gonna want to do is, um actually, no, we'll just do that on the update frame. I was gonna have it checked here to trigger the next scene. We're just gonna actually handle this escalation trigger here under this single player escalation. Check here where it's going to check, Um, whether or not it's time to spawn more enemies due to eat their escalation or because all of the enemies have already been killed. So all we're gonna do when an enemy is killed right now is increment. The players score so back to our enemy itself. Here, we, um, are going to have it, um, actually have some movement attached to it based off of the, um, speed that we give it. So we're also going to, um, have it en able or disabled light that is attached to it, depending on whether or not the enemy itself is actually activated. So here we can do a void start. Um, that way we can check as soon as this enemy respond If it'll check if the game mode is actually active or not, or if these air going to be enemies that are spawned at the begining of the, um, single player ruined you. If the state manager dark current game states is equal, Teoh game ST dot pregame. Then we are going to set ready, equal to true and the light game object said active is going to be equal to true, then, Um, that way. Um, if for some reason, um, an enemy is basically getting spawned at the last second that the game is not, um, or that the game is ending, then it will be set in a position that it's not going to be trying to move around or do anything else. So let's actually go ahead and create our enemy here would go back to our game. What I'm actually gonna want to dio is actually take, um, one of the pre fabs here. Um, let's go ahead and make it prefab for the player here. Um, let's go ahead and just save them over here the prefab and let's actually go and duplicate the player we're going to do. Something kind of simple here are kind of wonky, depending on how you look at it, it's actually make the enemy here, and let's go ahead and place them. Why it's moving over here for a little bit. No, read it. Zero. What's actually remove the player script and let's just flip this player over so that's good negative underneath degrees. You'll notice here that are because of the way our model is. You can actually kind of make it look like an enemy without even having to create a new model. So if we take a our enemy here can actually, just instead of adjusting the position on this, it's actually just adjust the position on the mesh. So let's put this back it zero and let's take the mesh itself Fear, like, grab all the components and will actually move these down so that now it looks like some sort of little ladybug or something we got going on here that's ready to terrorize us, all right? No, we have, you know, that's actually just irritation on this and or just irritation on these to be negative 1 80 instead, I think, and no, let's the way we had is should be fine, All right, So now that its position on the Z axis what we're gonna want to do, let's go ahead and it Let's change the color on these. Let's make him Let's make him regret their enemies after all, right? And then we'll change the body on this. Let's actually give them the player to look. Mary goes now they're going to be read very easy to tell that it's an enemy and here under the enemy, it can actually use the exact same animator as before. So let's go and create an enemy here. And let's go ahead and give a reference to the state manager. The enemy manager we haven't created yet. So let's do that now. Variables creates enemy Manager was called us the enemy manager here, the enemy types. We're gonna add this one as the enemy type in just a second. So now that we actually have the enemy manager here, let's go ahead. Make reference to it. Same with the, um, animator here that is on the enemy. And we're gonna make reference to its own rigid body and a reference to its own light and leave this, um, at two and three. Then let's go ahead and see this. And if we actually go ahead and just throw this in his pre fabs here, we can have a prefab to the enemy here. And then let's go ahead and remove this current one that we have. Actually, let's change the tag on this two enemy and it apply that way. It gets applied to the pre five as well. Double trick. It's under the prefab. Now we can delete this one, cause we're not actually gonna make be making any more changes in scene. So let's go ahead and delete this. And under the enemy, we have the enemy here. Let's go back to our enemy Manager for the enemy types was just gonna be one type of enemy right now. And we're going to add the enemy here, which is our upside down player. No. Now we actually have our enemy object as well as our enemy manager. The game manager is going to end up meeting your reference to the enemy manager as well. Let's go ahead. And just at this. Now top here, public enemy manager, enemy manager and let's actually get it to handle spawning first. And then we'll actually have it go back and handle, um, the movement of the enemies. Let's go ahead and make sure we can get them spawned first, and then we'll work on actually getting them to move and actually attacked Claire. So, um, what we're gonna do here under the wake method, we're gonna want to check if the game mode is actually ik cool to single player. And if it is, then we're going to reset the player, score the player. One player score value is equal to zero. And we're just gonna reset player Tuas. Well, um, that way. What? Um, if the game mode gets changed back to single player and multiplayer, it will have reset the score for both players. And then, um, that is all fine. Under the start, it's going to do the same thing where it spawned random blocks and where we're actually going to start. Having some different things here will be, um, for, um, single player. So we're gonna want to do, is under the single player escalations. We're going to have it Check here. Will do in else. If the game mode, um, it goes, um, came out a single player. And the, um, enemy manager not spawned enemies. That count is equal to zero. Then it's going to trigger escalation as well. Um, so by having these both reference just triggering escalation that way, um, we can ensure that, um, we aren't having to rewrite code or write code and more than one place. So here, under the escalations. Now, um, we have it doing the one thing for multi player, which is spawning bombs. And for single player, this is where we're actually going to go ahead and add in our, um, spawning for enemies. So again, we're gonna be rewriting very similar code to what we had before, which we can actually just take this prior code up above, go ahead and copy this and paste it down here. And I probably could have simplified this, but let's just leave it separated now, just so it's easier to read, Um, it's it's better to just have something code that is easier to read even if it is, um, I guess more lines of code than it needs to be. But it does make it easier to breed, especially for your newer to programming instead of or coming back to something after having not touched it in a while. It's easier to kind of look through this way, as opposed to adjusting its the other way. So all these bombed bombs spawned references we're gonna change the enemy spawned, and then here instead of, ah, spawning a neutral bomb, we're actually going to spawn a, um, a new enemy. So we're actually gonna add one new thing in here. We're gonna do an int enemy number. Um, we're gonna set this to random dot range, and this is gonna be between zero and the, um, enemy manager dot Enemy types don't count. And what this is going to do here is we are going to get a, um, random a random number here, um, between, um again between zero and however many enemies there are. So this number is actually not going to be, um, included in the maximum range for where something that could be selected. That's where we can just use the enemy count. So if you actually hover over the random range here for unity, you can see that the max is exclusive. That means it's not a selectable number within that range. So you actually selecting whatever you're actual max ranges that you want to be able to have selected and increment that by one. So we are actually gonna want to go ahead and take this the enemy number. And instead of the neutral bomb, we're going to be spawning the enemy manager dot enemy types and we're going to, uh, take the enemy number. So if we have more than one enemy type in the enemy manager here. It's gonna be selecting one at random, and then we're going to be spawning that instead of, um, one of the other ones as well. So now that we have this, um, let's go ahead and check this and see if this is going to dio what we wanted to dio So under the players Ready? Um, we already have this set up and under. So something to keep in mind under the max block here that we have under the max block value. We want to ensure that the Max book value is actually one larger than what we can actually spawn things at, um so if the maximum range for actually spawning blocks is, um, going to be, um, at one value, we actually want to ensure that this is going to be one, um, larger then where we actually wanted to be just to ensure that it's actually being included in that range. So if we go back here, we're actually wanting to check the maximum spawned position. He's actually, if we look at this upper corner here, so this upper corner is we actually wanted to be able to spawn, um, the maximum Is that what we're doing over here? Which would be this corner up here, which is negative. Four and five. And then, um, it's going back this up. Negative. Four and five and then, um, for and negative three. So it's good. Make sure we have those and they're under the, um, under the block manager. Um, so we actually want this to be We said we wanted it to be negative for and five. And let's actually take thes here. So the max block range on the X axis is I'm mixed myself up here now. So the maximum block that we could possibly have in the upper corner here is going to be again 45 on the minimum block that we can have is going to be, um, negative for negative three. So 45 negative for negative. Three, 45 So we want four and five. And, um, the negative. No. These ones, we actually want to stay the same because the minimum is is inclusive. And the maximum block a value is what's not inclusive. So these ones will stay at 45 The minimum block values will stay at negative three. Negative too. And we can actually double check this by setting the starting bombs that are the starting blocks. They were actually going to spawn to a much larger number. So starting randomised blocks. If we actually make this 50 this should fill in everything within the range we have. And because we put in the, um, the placement for where blocks could or could not spawn, we should see that they'll just fill in exactly where we want them to be able to fill in without actually filling in the other positions as well or without locking up the coat. Because we added in that thing toe, where if you can't find a position to place a block, it will just look through, and it will stop trying to place those blocks. So now that we have this corrected, let's go and save this change, the starting randomised blocks to something. Maybe back to 10 or back to eight. Everyone said it, too. Let's go ahead and get this saved here. Enemy manager. Let's go ahead and make reference to this and then let us, um, go ahead and start the game. Let's see what's gonna happen. It's going ready up. It should start up here now. Never go. It's gonna spawned one enemy, and it actually spawned them right side up. So it's just this here. Can we? Ah ha. OK, so we do actually want to adjust the rotation of the other things. So because we had the enemy flipped over. When you do a coup attorney and identity, it's gonna basically said its rotation back to zero. So we take our enemy here, we're actually gonna un rotate the enemy here. We're just gonna rotate its body by 180 degrees instead. That way, it has its little hands over here. Let's raise this up a bit. So it's not sticking in the ground like that, but as much actually go ahead to lifted at, um to talk to you about their we can leave its little hands and legs up there. That could be like tentacles. Now, let's go ahead and apply these changes to the prefab and then go ahead and delete it. And now let's go ahead and test this again. Let's test with our non threatening enemies here that can't actually do anything to us because they can't actually move. Let's go ahead and drop a bomb on them. And as we killed the one just 12 more. All right, let's go ahead and test killing these. Look, we can push me around right now. Let's go ahead and, uh, kill these and there we go. So as being and see as the timer goes up a swell, we haven't set to escalate really, really, really faster now. So let's actually make our own. Let's make a different escalation timer for single player because the, um, escalation time and escalation frequency is gonna want to be different for this. So let's give the player a bit more time. Let's set it about 30 seconds for each, um, so it's not going to actually start trying to escalate, um, until, um, until the player has been alive for quite a while, so we'll actually give him some time here, too, not get overwhelmed by enemies too quickly. All right, so now that we have our escalation said in place, we have our enemy created. The next step is going to be to actually insure that our enemy can move. So let's take our enemy here. We're going to go back to our enemy script, and we're going to add some movement to the, um, enemy itself so we can go ahead and do avoid update here fixed up, actually, because we're gonna want tied toothy physics engine. We don't want it updated depending on the frame rate, because then enemies air moving faster or slower, depending on how um how maney, How much FPs the player is getting? So we're gonna first during the fixed update. We're only gonna want to move if the game is actually active. So if the state manager, not current game states, is equal to Game State that game active, then we are going to check if the, um if the enemy is ready, then we're going to handle movement, and then we're gonna go ahead, and that's going to create the script, avoid handle movement, then here, um, And if the if the enemy is not ready than what we're going to dio is, um, check if the time that time is greater than or equal to the time to spawn, and then we're going to set the, um, the object to ready, which is setting ready to true and enabling the light on it. So the light is just another indicator to the player toe. Let them know that the enemy is actually awake and able to actually harm them. So the next thing from here under the movement, the first thing we're gonna want to do we're gonna want to set the, um moving Too true. This is the exact same animator were using for the player. So it's gonna be enabled in the same way, and we're going to do here is we're going to set the rigid body, the velocity equal to transformed forward times the speed of the object itself, and we're gonna make a great cast hit here. So with our recast hit that we have, we are going to use this to determine when the enemy should have an opportunity to turn. So we're gonna do i