Make Games from Scratch (No Coding!) Part 3 - Building a Breakout-style game in Unity with PlayMaker | Brandon Wu | Skillshare

Make Games from Scratch (No Coding!) Part 3 - Building a Breakout-style game in Unity with PlayMaker

Brandon Wu, Founder of Studio Pepwuper - a Game Studio

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
11 Lessons (2h 38m)
    • 1. Part 3 Introduction

      1:45
    • 2. Overview

      1:31
    • 3. Player Control (Part 1)

      28:00
    • 4. The Ball

      19:32
    • 5. Prefabs, Bars, Wall (Part 1)

      19:38
    • 6. Walls (Part 2), Roof, Floor

      21:08
    • 7. Parent / Child Objects, Random Color

      12:53
    • 8. Sound Effects

      16:35
    • 9. Player Control (Part 2)

      16:06
    • 10. Create Object (instantiation), Particle Effects

      10:09
    • 11. iTween Shake, Orthographic View

      10:21

About This Class

c5ca0817

Now that you have a basic understanding of Unity and PlayMaker, let's put those skills to use by creating simple interactions and controls and create a Breakout-style game! 

Transcripts

1. Part 3 Introduction: hi. Everyone will come to part three of our make games from scratch class, our unity and Playmaker introductory class. And in the 1st 2 parts, we've kept unity. We have also had a look at how playmaker works inside unity to allow you to make a name for the encoding. Now, in this third part, we are actually going to make a new interactive experience using Unity and Playmaker. We are going to make a game that's sort of in the breakout style type of gameplay, and we're gonna look at a few more things inside. Unity one. We're gonna do some player control. So we will get to the point where you can control an object inside the game using keyboards . And then we're gonna look at some basic in directions physics, pre fabs, which is a fabulous concept in unity, where you can duplicate things very efficiently. We're going to look at parenting and parenting objects, so group objects together and then you can make a lot of interesting things. With that, we're also going to look at San Effect and also instance creation, which means creation off objects wild against running. These are all really good bangs that concept that you can use for your games in the future , and we're going to learn off that using an example that we are going to go through here in Part three. So that's always if you have any questions, drop into four or you can email. May on. Hopefully you have fun out learning how to make this breakout star game. 2. Overview: So with three, we are halfway through the course, and I see that everyone is making good progress. So that's great. As you can see. I mean, my look Cuba again at home Monday morning, never made it to the office again. But this week we're going to do things a little bit differently in terms of the videos you're gonna be watching. Since we are recreating breakout from scratch, we're gonna be going through the steps, different components that needs to be built into the game. And I'm also going to talk about some of the concepts that we didn't talk about in the previous two weeks, and instead of explaining to you what they are, and some of them are really difficult to understand, if we just sort of like you go over the definition of thes turns instead of doing that, we will simply I'll give you a quick over the overview of what they do, and then once you start using them, you start to understand them. I think it through the whole concept of learning by doing right so that I think this is the whole idea of a project based learning. So the videos are gonna be about longer this time. Andi, feel free to your email. Me. If you have any questions, they might start to get a little bit more complex competitive before. But I think it's gonna be fun. So enjoy the videos and I'll speak to you guys in a bit. 3. Player Control (Part 1): So this week we are going to create a breakout style game. And if you're not familiar with break out, just do a quick Web search. I break out great, and you can find some information about how that game looks like what what that game looks like. But we're gonna create a simplified version of that, and I'm gonna do things a little bit differently this time just to see how Gehry's and we'll all start the project from scratch and see and basically walk through the entire process. Now this will be out, probably run into problems and issues. But I think it will be would be good Teoh for you to see how we can solve certain problems when we start to see them the first day. Of course we're gonna do is you want to go to the asset store or, um, progress for year? You would be using the custom. Actually, that's just do that Instead, go to That's it. You put package port could not have that important playmakers. Here we are, the things I'm gonna go to my claim Mater, they are great. The first thing we want to do is let's create a a handle for for the little born down at the bottom. And that the one that you control when you when you played breakout, right? So let me just change the color of the background. So, man, camera. That's the only thing in this scene right now. Just go change that a bit. It's no real reason to do this. I just wanted to make it a little bit more appealing. Right. Okay, I'm going to be starting that. Start with just creating a cube. Right? And that's just reset this que to its to the origin 00 their opposition. And that's skillet on the X. Texas, sir, it looks more like a boy. All right, okay. Position it down a little bit. We're gonna treat this later, but just for now, we're gonna do that. And, of course, we need our light. And so go to create directional light. Um, I think that's fine. I I always like to read reset position and so that we can can change that, but more systematically put this in the back so that it doesn't coming to you Seem we want manipulator. Other projects. Okay. Are they objects? Okay, so we have that. And I'm just gonna create a material for now, so create a material here. Why do I want to do that? I just wanted to give this box this. Keep a material so I can change the color. So I'm gonna say this is the to handle, Okay. And those. I'm gonna change the name your handle when drag this material onto the handle object. You cannot do that or do that. Contract it on top of the object in a seniors wrote. But I'm gonna do that here. Okay, Now this handle object, this cube has the handle material, all charges and end of interior so that it's a little bit less computing. And I'm going to simply change the color on the material Now. You can do that with any material you want. It's kind of a quick way, Teoh. Tiu have color for thanks. Minute. Anything that looks good. Use that color unless you can see because the lighting have this nice effect. Sort of different color on the different sides of the cube. It's nice. Okay, let's just go with that. Um and I'm gonna create a focus. Well, for just to keep things of it Tidier. We've that material in there. Okay? And finally, I want to create I want to save the scene. I'm just going to call it. Thank you. And I don't think would be creating more than one scene, so I don't need a scenes photo. That's fine. Okay, so So now we have a vigil representation off the handle for the handle. Next thing we want to do is going into playmaker and start creating a control. Right. So I want to create the control. Where? By pressing the left and right. Carol Keys. I want to move this handle. How do we do that? Well, that's add a statement sheen to it. So I'm gonna I'm gonna move this down here, see if, see if that gives us more space. Okay, so for this, I don't Okay, so let's see what we have. We need to be able to get to the left and right. He right. So a quick way to do this as by using Unity's imprint system. So we're gonna be using the unity input manager for this and let me just quickly explain what that does, and we're not gonna go into all the customization and changing the keys inside the input system, but we're just gonna make use of it. So let's go to this. Get access I should and what does This day this gets the value of the specified in FedEx's and stores in float. Terrible. See unity and put manager dogs right. So let's click on this question. Mike, the seals button here online help, and we'll go to the instruction page. And basically, in this action, you'll see that this Axis name multiplier, which I'll explain the minute and then you store it somewhere. And unity has thes default access that you can use to Teoh a set user imprint. Now you can go into even more detail by clicking out those length their unity input manager . And this is where you can define how the excess axes are access or defined, and the Empress manager is good added project settings. You put you have the input manager here, and then you can define these axes, and what we're most interested in is the horizontal axis, and you see that two buttons defined left and right button. Alternatively, you can use Andy and the whole bunch of settings here. But the important thing here is knowing this term or result, because that's the one we're using. You don't have to worry too much about these for now because these are all set up for you to use, right? So let's go back here and just tracked Get access. Okay, so let me explain that. What? Once once again, get access allows us to use thes axes. One of these access from the unity impose system again. It's added project settings, imprint What can use that action to access these input axes. And for now, we're most interested in horizontal. All right, so I'm gonna copy that name just because I'm, uh, gonna be using it here. Access name. So this has to match which control. ACS says we want to use horizontal multiplier as basically, um, when you use the excess unity will give you a number based on the key that's being pressed , and you can multiply it to a bigger number if you to. Basically, you can use this to change the speed and movement off. This handled by. I'm going to show you that in a minute. But another thing I want to talk about now, as you can see that there's this store option on this. This is non here and get rid of that for now. That's something I had created earlier. So basically, this area is where we can store the input into a slowed variable. Now, if you're not familiar with the concept off, variable that me quickly go over that so that you can see that I'm playmaker. There is a variables tab. Click on that and there's nothing here. So what was a variable variable? It's something that varies, something that can be changed, something that's changeable. Think of it as a container box that that's empty and you can put different things in inside into the box into the continued. So, for example, if I want to say okay, I want this box, Teoh, hold a number for me and this number is going to represent the position off. Uh oh. Actually, that's that's do a simple let's say, if I want a box that contains a word and then I can change the word two different now, right? So I can say Okay, I wanted the box the variable to be cold. Now, basically, I have this imaginary empty container. And then the label on the container says word and type off. The contender will have to be a strain. A string is a variable tired that handles taxed handles any sort of tax shrimp it So I can say the word in this box as we read. Or actually, it's apple. Right? So now you have this imaginary container in the name of the content of the label on the container is word and inside is contained. We have this stream of tax and that's that tax is apple, and you can change this to something else we can say, Well, I want two. I want this word container to have a stream instead of apple apple. We're gonna do, um, corn. Now all of a sudden does contain it with the label. Word on Don Top has two straight orange in it. This is a little bit abstract, but you'll see how to use it once we start using. So let's create before we go. Go on. Let me just talk about some of the different variable times that we can use. So when you when you before you create a new variable, what you're creating a new variable. That's that's call. Let's say what we're creating an empty contender with a label are for him. My change that. But let's just say okay, I'm putting a label on this container and the label ist movement. Now I need to define what types of objects, what types of what kind of things that can put inside to continue. And that's defining the variable type. So I think the most important ones for us now. His float So float just means and number with decimal points. Now it means more than that, but for our purpose. That's just remember slow as any number that's not an intelligent right. So a number with decimal points into pairs interject, which is and interject mathematically speaking, pull type as imagine if you're trying to answer, yes and no question, right, so a bull, a boolean variable can only hold either yes or no inside the container, So this is useful when you want to say, Well, is this door open yes or no? That that's that you will be using a boolean variable for them. You can also have the contending contain a game object now a game up jerk is any objects of here that we create that we, including the scenes where you can have to contend and hold that game object stream as as we just talked about string a string variable holds tax, a string of tax. It could be one word. It could be a sentence that could be a lot of different sentences altogether. So, basically, just remember, string variables are for text. That's a to we're not going to be using that, um, and back to three is important. So so basically infected. Two directors three are used hope to hold multiple values, right? So Vector three holds on accident. Why? And it is that value, right? So three different Sloat valleys. So think of it as a huge continue that's divided into two parts or three fights. If it's a rectal, too, then you have this contender that's divided into two parts, and each part can hold one float. Veritable. Vector three is a big continue that has three compartment inside, and you can put three different float. It can put three different numbers into this one. Containment. There's one vector three containment color variables are fellowship for what it is it's a contender. The help available for the color so the color could be It could be white, red, any kind of color that you can define their very Ferris different ways. You can define color, but a collar variable will hold the color. We're not gonna be using most of the other ones. We'll get to them when we we need them. But for now, I can just remember that a variable as it container that holds different types of objects, of different types of things. Now here's for a purpose. We want to move this bar. This handle and what we need to do here is we're getting the horizontal axis and we're storing that number in a variable. And then that's just creative movement. Variable. Now it's a float. Very well, because I wanted to be a number with a decimal points and I'm going to store here movement , right, so you can make sure that you have this deeper check so we can see that the value of that variable and in this variables tab, you can define the value here. If I change that to five, see that now it's five, but I'm going to keep that zero for now. Okay, now, if I run this game, you'll see. I think it's a little bit easier to explain what we're doing here. So another thing is, we're running just every friend because we want to get the user. You could continuously accidents will run the game. Okay, So without touching the keyboard, I can see that there's no change in the movement. But as soon as I start pressing the right button, you see that the movement has gone to one from zero goes from zero. As soon as I start pressing down this right up T was from 0 to 1. And then if I press down, Lefty goes from zero to negative one zero to negative one. So you want to be looking at this? So this is how you can use the unity improve, manager to get to convert an input into something you can use in the game. Right? So hopefully I've demonstrated how you can use that Now, this is where it gets interesting there. If if I change the multipliers to 10 so the game is played. So this is not gonna be saved just fine. Just for the demonstration purpose when that Show me the game tape and I got when I pressed too, right? No key. It goes from 0 to 10 instead of 0 to 1. So essentially the multiplier multiplies tend to whatever number the access in practice giving you. And how is that useful? What? It's useful in next step where we start defining the movement. Stop this could The next step we want to do is that we just get rid of this state for now. I don't know why I created it. Just don't have it. So the next thing we want to do is traps using this variable that we have to moves the handle. Right? So let's go to the action browser again and we want I won't transform. Remember, transform as the component that managers the position and this scaling and rotation off the object. And now what we want to do is we want you want this handled to move on the x X. It's like that right again. The red handle here The red axis here is acts. It's good before you reset this to their own center again. Actually, browser transform translate drug trends Day down here and it's very simple, right? So we are. We've established that we want Teoh move along the X axis. So it's just so okay, take the movement very cool, and then apply it to the x X. It's a movement long Steve X exodus on. We wanted to dio every per second every frame. I think that's that's fine. Space itself is fine. So Okay, let's see what that looks like. Chris plane. Okay, now, when I click on when I pressed the right button, you can see that now we're moving. We are moving left and right. So that's fairly simple, isn't it? Right? So again, let me explain when you press down the button, we're getting a horizontal data hours on the input data from the system. We put that data into the movement variable. And then down here, they're moving the object in the axe nexus with that data with that number. Because the next thing we want to do is this is moving a little bit too slow for me. So I want to make it move a little bit faster. And as we can see previously, if I change the multiplier to 10 I will transfer the I'll change the way this variable is going to present. So basically I'm mortifying everything by 10 which will translate to which will be that in the translate. Action will be moving faster as well. So let's just see how that's that's working for us, right? Okay. Multiplier is now 10 on your attention to this farrago here. We're going from 0 to 10 reserve until you live 10 instead of 0 to 1, and you can see that this is moving a lot faster. If we scroll down, look at the translate that you see that it's translating. It was a bigger number as well, So that's where we can just the speed most handle. Now what I want to do is stop this. Make sure you stop the game when you want to make any real changes. I want to make sure that we can just this speed variable. Let's make this into a speed variable so we can adjust it. I can adjust it without coming into the state. Michigan. Let's go to variables, and it's gonna be afloat because it is going to be a number with dissidents, corrector state and click on this button here. This will allow you to switch from manual input to using variables. So I got the speed variable here. It's used that and let's go back to variables. Right now, the Speed Valley is zero. That's not good. So that's put one. That's that was the default one, actually, that's move from Yes. Okay, let's do one. And you can see that multipliers back at one. And if you play, this is going to give us the same speed as we originally had. Now I can change those two again. 10. You go back to ST See that That's changed. Let's play. We're going at a much faster speed, so that's really cool. But what I really want to do is I want the ability to change the speed without going into this scene. Right? So what I want to do here is I want I wanted to show up in the Inspector, and it's very easy to do that. Just click on speed and check, inspector, and all of a sudden you can see that now is showing up here so you can change the number here, and it would directly change the value here Now this is handy because that's see, let's say if I'm looking at the project, be or look into camera. And now I want to change something. Handle can click on handle. I can just change this feet get right and also you can give it a tool tip so I can say speed of the angle. Now, when you hover over this option, that's going to tell you it's going to show you tilted. So this is really handy when you have when you start to have a lot of variables that you see Indian, the expected you want quickly understand? Remember, you want quickly. Remember what the variable does. Okay, so let me just demonstrate that once again would quickly hit play. No, I have to speed 10. You can dread right next to text Field, because would have changed it value there. I'm five now. It's moving at a slower speed. Choose that 2.505 Now it's moving at a really slow speed one. So another thing that's great about having a speed variable is that you can have things in the game that changes this favorable so you can dynamically change the speed off this hand . Oh, see, rather events through other triggers. Other objects that could potentially impact your gameplay. So get now we have we have a handle control created. And then this is actually not night o state anymore. So what will change this to moving business? Okay, safe the next. 4. The Ball: Okay. The next thing we want to do here is creating that ball that's gonna bounce around, break out. So let's see. How would you do that? First of all, I think I'm gonna change the name of the subject. Just because I don't know it's not really is Handover is that it's more like Just call it a player four to see the name, but But that would do. Okay, save it. Okay, so let's create That's great. A sphere to represent the bowl, the name, and I'll make sure I want to make sure that it's properly lined up. So that's reset position. Double click on it. So man and I want to make sure it's on top directly on top of player. Or there's a click again. Click on the wine here, and then I'm gonna change this. Teoh you know so well. So graphic you just help me line this up a bit more so I can see. Okay, it's probably lined up here. If I just keep it zero 00 that actually works fairly well. Okay, Now we have this. Yeah, Doesn't do much right. If you play, it doesn't. There's nothing going on you can move your oh are down there. But it is. The bullet doesn't do anything, so that's at some interactions to it. Okay, simple ad state machine. And we just say move. And, um, we're gonna use Sam action. We're gonna go back to transform and translate again, translate as how you would move an object. There's many different ways to move an object, but trans translate would allow you to directly changed to transform here, which if we change the transform, you can see that it changes the position or different properties here. So use translate to change the position on the transform. And what we want this all to do is, well, I wanted to go down on the Y axis and there may be go, it's that said, Let's go left on the X axis. So what sort of coming us, Diokno said. Van Gogh here. So let's just do an experiment. I'm gonna manually impede some numbers here. So for acts that I wanted to go and why you want to go down as well, So let's put negative three, both of them. Both of these excess tensions have play. See that all moves that might be a bit too fast. Free season. I'm gonna change that negative one. Try that again. Now the ball is moving, but it's not interacting with the player bar, this little boring that were controlling here. So what we want to do as we want the the ball to go to sort of bounce when it touches the when it collides with the Playboy, right? So how do you do that? Well, that's just think about this. Think about this for a second. When you when the bowl touches the bar, you want that, you want it to go up. You said it down. So you want to flip on the Y axis, and also you wanted to go essentially. See if you go down this way, because in the expects is, we'll deal with that one later. Let's just make it bounce first. So instead of going down, wanted to go when it touches. The bar wanted to go up right? So you. That also means we need to be changing number here on the Y axis. So since we have to change this, this needs to be a variable. So it's kind of variables, live movement and back here or your wife movement. So make sure that defined this the negative three again. And I wanted to be accessible here. Just makes it a year, right? So, Inspector, check that shows up here, okay? And the next thing we want to do is add another state and in this state will say, And what we want to do is we want to slip that terrible float, need apply. So we're gonna multiply that wife movement by negative one so that the negative three becomes a three, which means it will go up. We're gonna be increasing the why. He said, if decreasing it and I'm I want to define the event one would make the switch. Right. So that's gonna happen when this bowl touches the handle boy the player boy. And we're gonna be using the collision event. So just bear with me for one second. That's give this a try. Go to add transitions. So you're right. Click at transition system event, and that's to collision. Connect those two. So this is saying when there is a collision. When the ball collides with another object, I will go to this other state and will flip the number and then, when this is finished, would go back to the moving state where the trends they were again moved the object for us . Now let's try that. And before we continue, I'm going to just let you know that this is probably not gonna work. And I'll explain why in a minute. But let's let's try that first play is going to go there. It's just goes right through the other object. And why is that? It's because we don't have a Richard body on this particular object. Now this topic is a little bit complex, and even now, location, we'll be a little bit confused. But when it comes to what can interact words so there are different types of objects, their own colliders that we have here. And if we click on its trigger than this, all of a sudden is no longer just a collider is now trigger. And then we have this physics component called Bridget Body, and you can't go to I'm gonna post just like here on the Forum. But you can go to this link. That sort of explains to physics system inside unity and primarily talk about Richard bodies and different types of colliders. But for our purposes, what we need is, if you just keep scrolling down there is this table here. This is collision action matrix, and this is the important one. Because whenever you feel that confused, you come here and then you can check what can interact. With what? Don't worry if you're confused, because this is definitely confusing. But hopefully through making these changes now you have a better understanding, right? So now let's click on the player boy and see what this is. So this is a standard collided. It's not a trigger, and it doesn't have a rigid body component right now. What? What is a rigid body component? Rigid body. This. You can add it here if you go toe had component physics region body. And this allows this object to interact with the physics engines. Our unity. Right. So just remember, that region body allows you to interact. What physics in the game. Right. So let me remove this just for now. So we've examined that this is a collider player boys collider. And this ball is also a collided right Now if we look at this matrix here ecstatic collider does not interact with another static colitis. It doesn't. The collision detection doesn't occur. And collision detection is what we're using. If you remember, we were using Collision. And so if that event is not happening, then we don't get Teoh transition to the other state. So what we'll need as a cold lighter? Sorry. What we need is a rigid body. So if you look at this chart, a static collided well interact with a rigid body collided. So that's that's good information. So that's at a reach of body to the ball and what we want to make sure that we turn off gravity because we don't want to use gravity. For now, we're manually moving it up and down. Turn off gravity. There are various different options you can treat. Um, again, to click on that help button will give you explanations of off the region body component. Um, but we're not gonna go into that for now. Okay, so now let's see if that works. So according to the matrix, that's, um, try that again. The rigid body collided. Well, interact with static. Collided. Right. Okay, so that's that's good. So if if we had play now it it just interacted with bar. And if we do that, sterling Is that still frame by frame? Concede that actually back off a bit, right? So it is moving towards the bar. You can see that and then we're just gonna go frame by frame. Or I think I just, uh, went to the next state. Hello again. Thank you. So quick. Note. If you click on that, they will go to the next state, seasonably right. And if you click on this button here, they will go to the next frame, which is what I wanted to be a says. That's let's take a closer look. Now you go closer and closer. It's going to touch born, and I don't know if he noted, catch that. But it went down to the state quickly and went back to the move state. And you can see that the why movement is now positive. Three instead of negative, serious we had previously defined, So now it's going upwards. So that's that's useful. That's good. So with taking care of the movement on the Y Axis, which is controlling the up and down movement of all, I think about how we want it to hes our intensive movement on the S axis. So sometimes when when the ball heads boy, you want to go continue going left. Sometimes you wanted Teoh switch direction and go right. And let's make that into a random bearable. So basically one, the ball hits the boy. It would just rent, um, randomly decide if it's gonna go laughable. Right? I see you found that. That feels right. So how do we do that? Well, a quick way to do that as well. First of all, we need to set up open access movement similar to the white movement here. But we're gonna use that for the X value here, so it's not always negative one. So, Steve, at first at a new variable. And I'm also going to experience it in the Inspector. And it's just so you can sit here and I'm gonna say OK, No. So what? The X movement is negative. It goes to left. Yeah, we move into the last. Now it's a negative position. Um, and let's start with that. Go back to the state again in the translate action chance this to variable ex treatment. Okay, Now, one a collision happens. Go to the foot state and this is how we This is where we change it. Teoh moving upwards for the y axis. But here's another thing I want to do is I won't add a random event. I saw you seen the state mission, so that's that's done. You cannot do a search like what I just did. Their state machine and Teoh rendered event. So let's let's see what what this does click on that question mark button, but the center Brendan event have to delay. Now we're gonna eat, But we're not going to use DeLay. But we are going to use the random event, and I'm going to add a new state here, and this is gonna say, and then the event, we're gonna add one more customer event told that's just for different names. For me to to remember this easily. Okay, Now go to flip. Had transition flu packs. I'm gonna click connect that there and say finished event goes back to me. So let me just explain this a bit. So what? I'm essentially doing this. When the collision happens, we go to this state where we know for sure we're going to change the direction on the Y axis. So if you're moving down, we're gonna go up. And I say, if you had something, both you're gonna go down. But what we are not sure if we want to do is what we want to render mines. Is the movement off left and right? So by adding this random event, which means But you're here, the game is either gonna go to finished, go back to moving, which means there's no change to your acts movement of terrible. So if the ball was moving life, so continue to move left. But if Assistant decided to pick the other one because since it's randomized, it's rendered event will just pick one of If you picked, the other one will go to the Flip Packs movement event where here will do the same thing as we did here was Switch will flip the movement on the on the X axis. So you, if you were if you were moving to left, then narrow be moving to the right. Okay, so that's that's the Senate click and flip. And I'm just gonna simply copy this copy. Slow point, then pacing that make sure that we are now changing the tax movement. Okay, so let's hear if that works to play. See now I just moved to right. So that's kid. That means it's behaving differently, and now it's moving to the left. So every time when the ball has four, you have it potentially different outcome. It's all randomised, some very offense right now, because we are essentially replaying the game over and over again to try out that rendered randomness. So that's good one. One way we can manually change testes again. This now with faucet. It just sort of it just went through these states. Now we're positive, and I want this ball to come down again. Just for testing's been many chances to negative three. I'm foster game. See that? Now It's moving. All right, friended me. Okay, so I'm pretty happy with this, and now we have movement. There's on the X axis and the y axis for the ball whenever it interacts with the players. Boy 5. Prefabs, Bars, Wall (Part 1): Now I've got a basic set up for the control of basic set of for the ball. What's the next thing I want to do? Let's see, I think this not only might want to make the camera gonna just reorganize, reorganize things a little bit. Okay, I'm gonna move the cat. I think the camera is a little bit too close, so I can't see much. So we're gonna move the camera back, and, uh, let's just do this the easy way. For now, we're gonna simply pull the camera back on its easy access. You can see that as I do, that changes there so that it moves away from the objects and then they become a bit smaller and we're just gonna sort of three position. It starts. Gives us more space at the top, I think. Let's go with something like that. Okay. And then another thing we need to have a say. We need to have these bars at the upper part of the screen when you play more for a breakout, said it. So since I have this player bar working, I might just duplicate thirst and remove the interaction. Actually, I think any Cube woodwork. Let's try that. So let's just create que And, uh, it's a position that gravels Obviously we don't want it to be there, So move it up a bit, and then scale press are to scale tool and then just scale up the the on the X axis. Remove this. Change this to round number. Okay, so I'm gonna say this a and it's just fear of these. So that would make sure that we block this way so they always hit at least one of them. Let's see, from how we can best do that, there is a short short cut for you to duplicate an item just control D o command. D you do that? That's gonna create dupe. Okay, just do that and pay attention to this area. Command de control de. You can see that there's another one being created and is going to be created at the same spot, so you can't actually see it in the scene until you start moving it. And now you can see that there's actually there are actually two objects there. So let's just do that a few times said duplicate Okay, means okay, lets see a phone that works. Oh, yes. We, uh I need one more, and here, just to make sure it's captured, capture everything, and I'm gonna move the camera back a little bit more. Just just for now. So? So we can see if this is working. Okay, so it is working. It's reacting. The ball is reacting to that colliders kid colitis. Okay, so that's good. Um, it's great. This one up a bit, okay? And move the camera again just so that it looks more like. Or we'd expect just by you can you can adjust the ve just by reposition in your camera. I think that that's roughly right. Okay, So the next thing I want to do is I want the bars to disappear, one their head by the ball, just that That's the behavior. We expect a break out game. So, in order to their several different ways to do that and across multiple up objects, because we want that same, um, well, in that same direction on all off the boards that we're going to create and there are multiple ways to do it. What? I am going to show you now as the concept of a prefab. So a prefab is well, when you think of going to put a prefab is basically an object that saved in a system that you can reuse so you can reuse the same object over and over again. And it's always going to be the same. 1 90% of the time is 90% of it. It's going to be the same. So think of it as a think of it as a cookie cutter, right? So whenever you use the cookie cutter, you're gonna end up with the same shape Took is always gonna have the same shape. So So it's kind of a similar idea, and I'm gonna show you how to do that right now. So, first of all that's removed most of these. It's just ah tro delete command, delete, move them and start with just one. Now let's go to the project. Do you? And I'm going to create folder cold, and that's where I'm going to store all my pre fabs and again, pre fabs is just a term for these things that you can continue to reuse, right? And how do you create a prefab? Very easy. You just drag this object into the project. And now you can see that there is a boar prefab on. If you look at this, found him down here, it's good dark prefab extension, which means this is a prefab. And also, if you change the view to a list for you, it's going to have this sort of Blue Cube Icahn. And regardless of what the object is, it's gonna have that icon. Okay, so that's good. And you can also see that it's kind of subtle, but the tax on the file name has changed to a dark blue tax color, and that also indicates that this is now connected to a prefab. So this object in the hierarchy is connected to the prefab in the project. Okay, so another thing that you notice is now this object has this line here That's that's prefab . And then select Revert, apply if you go to another. Any other objects is not counted to a prefab. It wouldn't have that line, sir. There you have the profound my there you don't. And this is a quick way for you to find. Okay, If you click on select, you also mathematically select the prefab that this subject is connected to. So, uh, that does try, try this can just delete this subject here. And don't worry, we have a copy of it here, so there's no bar object in the scene. You can just drag and drop this to the scene. Now you have a bar, and you can just keep doing that. Keep creating multiple objects like that with the boys from that. So So essentially, you've created an asset that represents the object that you've created in the scene. And the cool thing about this is that, say, if I make changes to this prefab, then the changes will also apply to the objects that are connected to this previous. So you, for example. Uh, let's see what I want to do with this prefab here. Well, since we are going to create some interactions for remind us, we'll add a playmaker component. So let's add the playmaker affects him. So this is the same as going to play maker and right click and then at present. But make sure that you have the prefab selected instead of one of these, and you can see that as soon as we added this component this playmaking component. All the ones of here have that playmaker icon, which means they are now also play Make objects. Dave old now have this component attitude them. See, they all have this. Now if I go back to the boar prefab and remove this no, sudden. None of these will have that playmaker component. So that's the idea of a pre fat is you can use the prefab to duplicate objects being any scene and changes made to the pre facts are going, Teoh apply to order objects connected to it. Okay, Now let's add that back because we do want to play making component on it, okay? And just call this, um Troy. Okay, make it more. Maybe a bit too descriptive, but I think that let's go with that for now. Headed to you Have playmaker tab. Okay, Now make sure that this has this has pre fact on it. Because if you make changes to the individual objects here instead of the prefab that the other ones won't have the changes you made to make sure when you make changes to pre fabs, uh, you are making changes to the pre fact where you want to make changes that applies to all objects connected to a prefab Make changes to the pre fat itself. Okay. And we're just going to say the Idaho State, which is basically saying, Don't do anything, and then we add head State. So when things bars head, we do something to it, and we're gonna add a transition. And we're gonna just through coalition inter and then drag that to the hit state. And when we want to do here is to destroy self, right? So there's this action will destroy itself. And all it does is destroying this object. And that's it. No, I've seen some errors that See what? We have missing targets day. Okay, so there these are old errors, I think. Yeah. Okay, so once that prefab, So we make changes to the prefab, and you can see that all these objects now have this playmaker component, and they'll have the same, um, state machine design. And you can tell that these are not the prefects by looking at this thing here is as prefab since that's instead of pre fact. So if you see this whenever you see this phrase prefab instance, make sure you go to select prefab and make changes there. Otherwise, the changes you've made will only apply to one particular object. Okay, so let's see if see if that works Play. Let's hope it hits something. Yeah, there we go. Ok, now can see that when the ball heads the bar for just simply dis choice itself. Okay, that's good. I like that effect. Now, Uh, let's just to do a little bit of experiment now. Another thing with prefab vis, you don't always have to drag this into a scene. You can also just duplicate any objects that's connected to prefab. Or you can just call them proof. Every in census, you can just duplicate them by using. You can always do control C control V, move it or do what we did earlier. Trump de Committee. So I'm just going to start making hope onto these just randomly. This doesn't have to be any, would it? Right. And, uh, So you can also hold down, shift and select a whole bunch of subjects at a time to click on one object, hold down shift click on the other ones, will select everything in between, and I'm gonna just duplicate this whole thing. Holy objects. Here's a control D and move them up like that. Okay, nothingness. Objects first to destroy on deaf boys first to destroy. So let's play this and see you how that works. Okay, So slight problem here so you can see that the ball is flying off the screen, so we need to set a boundary here. Um, I was gonna do that later, but since since we're experiencing this problem, that's that's fixed that now so safe the project and let's create a boundary there. Right? So how do we do that? Well, as simple, because now we know that the bowl will come back. One of it hits something. So we need to do is just creating a wall here, and then it should theoretical come back. Right? So let's create a cube. You can call this wall and store it ISS. Okay, so I'm gonna be sent it and move to left hand side. Now, you can always do this and look at it from the back. I am going to scale it all the way up and move it up a bit. Maybe something like that. Closer. Okay, so I'm going to so you can see that it's over there just to be safe. I'm gonna skillet on the is the access just so that it's it's a little bit bigger. That right then I don't want Teoh effect actually, might be kind of cool. You can see that visually, to see, like a an interesting effect on the scene as well. So I'm going to keep that Okay, now that's duplicate that wall and they move it aside. Okay, that sounds safe. That and, uh, play now you could say that the four has attached. It's just, uh, not bouncing off the wall. And why was that? That's try that again. I have an idea why that's happening, but that's let's see how we can find out exactly what's happening. So again, it's going that way and thats why don't heads the wall? So far, so good. It's not we're not seeing that fuckin, but we should see it can fairly soon. You can see that won the ball is changing direction on the X axis of wife on the wall. Catch that it doesn't have any public. Okay, now we're seeing the problem. It's pause it and click on the ball in just two. Let's try to find out what's going on here. So let's click on the ball and go toe playmaker. Okay? Sometimes it doesn't show up. I just select the ball again and thats let's see what's going on so you can see that is currently cost and the ball, as in the move state. Right? And let's see, it's got the negative three on the X X is in the negative three on the Y axis, so that means it's trying to move down and at the same time trying to move left. And that created a problem for us because if the ball keeps trying to go left, it's going to keep thumping into this wall and you wouldn't bounce off the wall. All right, so we're gonna need some logic to toe the ball. Well, if you hit the warm loved, always go right if you hit the wall on the right, always go left incentive. Instead of randomly pick one of these two directions to go to us. We have designed earlier, right? So that's do that next 6. Walls (Part 2), Roof, Floor: So let's think about what we want to do here, the current said. It basically means whenever this ball hits anything, it's going to change direction under Why? Which means if it was going off, it's gonna go down. If it was going down, is gonna go up and Michael left or right. It's trending randomly selected, and that works fine. But I think for the wall what we want to do is that sounds see if I can show this to when this ball hits that wall. We wanted to go that continue, go in the same direction on the y. So it so it was going up like those. It should just continue to go up on the Y axis but changed direction on the X axis. So that behaviour is different and the ball needs to know what object it's hitting. What kind of object this ball is was hitting, right? So we're going to need to change the behavior off this ball a little bit, right? So let me just reset with the ball and, uh, go Teoh being playmaker editor for this object for the goal. Now I can see that the current set up as as soon as there's a collision with foot. The why and with my flip the axe, any other rendered event. What I want to do now is I want the ball to know if we're hitting the wall or not. So that's going to the wall. Okay, so let's see. Okay, that's that Feel with the left one. First, we need to give this a tag, sir, if you if you look at the inspector, you'll see that there's a tag option here. And this is one way for you to put it, Another label on the object. So the object has a name that you can use the name to find the object, but it's a better way to do it did to do things. If you can assign tax to object. So we're gonna do that. And if you don't quite understand it, that's OK. Once you've done this, you know what we're doing. So go to tag and we're gonna add a new tag. Click on that tag and you'll see this tag manager tool. You can use this to add tags and layers. We're not gonna get into the areas right now, but it's open up tact and there's no tax here. And we're just gonna add new one called wall. You can see that as soon as you start typing the system automatically adds a new empty tack for you from ADM. Or I have three. Okay, um, acceptable. But I'm not going to use that many. I'm gonna change this back to two. So we have I just added that the wall tank, and now this is a little bit tricky, but go back to the wall. We have to go back to all and then select tack again. And then So So, like, wall, This is the new tact. There was just added. And make sure that you do that for both walls, right? Okay. So that they both have the tag attack walling off the Wall Tech. You always have through all time. Okay, good. Now let's go. Go back to the ball. And the next thing we want to do is I want to create a new state and this is for only one when that the ball has the wall. So goal right. And we need to change this event because we don't want it to go to always go to the flip state when there is a collision, right? So I'm going to create two new events. One is called Pit, and the 2nd 1 is So when the ball heads the wall, we wanted to do certain things. And then if it's not the wall, different behavior, right? So I'm gonna chance this collision. Enter too, head others. Right? So this basically means if the bowl had something that's not the wall, then there will go. If the ball hits something that's not all that will go through our, you know, usual State will go go through the foot on the Y and then maybe flip on the axe. And then I'm going to add a second transition called Hedwall, and that's going to go to the wall Head state. And this is when we will flip the axe, but not the y. So we can either copy this a place that here is a multiply X movement by negative one. And then we had a finished state and go back to move that we kind of do that. Or if you want to be clever, you can also just connect this to the flip X State Essentially, these two are the same, so there's no need to create a separately. But just for now, I'm gonna do that because with my one ass and different effects later on down line to whenever they hit the wall, maybe will play a different type of sound. So it might be good Teoh to use a separate state for that. Okay, so So we've got the events. We've got the States. But what's missing here is a logic that's going to you know, which events to to go to because right now we have a translate which moves ball, but nothing else. Okay, so that's that's going to the action browser and go down to the physics tab fix physics category. And we want to do what we want to do is add collision events. Right? So this basically gives you have been more control over the collisions. So it's going Teoh. That's just give it a try, and then you'll see what I mean. It's for that in Uncle Login. Enter right. So this is similar to what we had we had before. Collision Enter when there is when When the object enters a collision event collision State when a collision happens. Coli tack. Now this has the tag that's on the up, the other object. So when the ball heads the wall, it's going to return this tag to the balls. It's going to return wall tack, so we're going to change this wall. So want the ball hits the wall, so hits any object with the wall tag. Then we're gonna go to the event hit wall, and that's when it's going to go to this wall hit state and then flew the axe Excess foot, the Valley of Max movement. And it's at another one, another collision event. Then let's drag this damn again. We're gonna put down at the bottom, right? So the first we have when you collide with the wall, go to hit wall. If there is, the object is not tagged, and the war is eternally the only object that's attacked. Everything else there are no tax on the I'm gonna keep that has untaxed, and if you're not sure about it, click on bar. You can see that the tag is intact. Even the player boy. It's intact. So So I think that would be fine. And then this is when we go. Okay? If if the other object, it's on tag, then we go to the hit publish event. And that would mean that will go from this state to the hit of this event and then go to float. And then I'm gonna change this to flip one. It's a little bit more descriptive, and I'm just gonna change this to just flip acts just for consistency. Okay, so I think that should work. I see hit play and see what that does Might be a while until the ball hits the wall. So that's that's changed things a bit. I'm simply gonna move, click on the wall. And it just moved wars closer to the players. So So just so that we can quickly test this. Okay, play. Okay, so the seems like it's Ah, it's working right? So when the ball hits the wall, it's simply changes the direction on left and right, but continues going up or down, and it doesn't get stuck again. So that's good. That's what we wanted today. Okay, so that's good. Uh um, play and then just I do too. Change. I undid the movement of the repositioning of the walls. Okay, so you got, um so that's that's give this a try. And I'm just gonna play this and see if we're missing anything. Okay? So pretty much everything you would expect from a breakout style game. A little bit slow? I think so. Sorry. My increase. The speed on the ball. I think that's probably the most fun. Let's do that. Now. Come fall on. See, Do I have pave? I don't have a speed. Terrible, but that's okay. Um, we can just make it would change this number here. This is number that we want to change. Which do you make of 77 play and see if that feels a little bit better. Yeah, so that's that's a lot faster. So that's good. And of course, another thing you can do here as the ball is going over rave on. Just there's nothing to stop it from moving at the top. So we'll add another war top through subject there. Um, but nothing you can do with with the ball, as you can create a separate variable called speed, and you can calculate the why movement and ex movement based on that speed. But I don't I don't think that's necessarily I don't think it's necessary for now. And also you might 12 have a little fun with it. So you might want it to go slower on the war and then found the axe. That looks like it's just test this. So the movement is sort of flatter, right? So it doesn't go up and down. It's as much as much s t the axe movement. So you can you can sort of change the angle off movement there. Okay, so I'm gonna keep this asked. 77 That's that was a good feel, that film quickly. So let's do that. And let's just pick a Ruth Tom again. The cube que go, um and I'm gonna change this. Teoh chose the name, too, and then scale it. Actually, that's reposition first. So is everything. Is what about the same, um, see, what are the same z position? So make sure that the ball can hit it, and it's just scale this up. So careful overlapping with all that. I think that's a public and maybe just a little bit z sprout. It doesn't matter. I think it looks good that way. No, I think that that's right here. And do I want to change the behavior of the ball when it hits the roof? Let's think, brothers. I think it should be fine because we wanted Teoh change direction, Sort of. It's going up. It should go down and, uh, do we want to change the direction of acts? I think it's fine to leave it random, So So that's fine. So it's safe at. And if you want to quickly test that, let's click on the boys. It's like all the boys and just deactivate them for now, just for testing. So they're all going from the scene. That's just play. Okay, so the ball it's moving, going up and it hits the roof and it comes back down. So that's the behavior we wanted. So that's that's good, cause it stopped the game and activate the bars again. OK, so that's good. The next thing we want to do here is we want the game to restart one over the ball force food eso whenever you didn't catch the plate whenever declared, doesn't catch the ball, then restarts the level. So I am going to duplicate the roof just because I'm a little bit lazy. Didn't wanna recreate Cube, and I'm gonna hurt this new after first of all, I'm going to change the name floor. And that's the somewhere. Yeah, just below just below the player object. The playboy here's fine. Okay, Safe. And this thing here, we need to give it a in action. Now I cannot add the action to the ball to say, Well, when you have the floor, we started the game or I can say I can put it on the floor of Jack and say what a ball hits You restart the game. I think that would work. So, yeah, let's let's give that a try. So floor right clerk had a state machine, and usually before that all hits you. It's your in the Idaho State. And then when the wall hit you, when the ball had she, that doesn't really matter what name you give in German. And here I'm just going to use a coalition event because nothing else is moving in the same . So there's nothing else that would collide with with the floor. Actually, just to be safe, that's that. Let's not do that. That's actually not the best practice here, so I'm going to create any tag for the ball as well. So we can You can recognize the ball, right? So let's go to cat tag and at a full time, go back to your ball, select the ball tag. Now, the name doesn't have to be the same. So change this to power. Other names continues around Fehn Okay, I can name this round thing. It doesn't matter because I can still use the tag to identify. There's object anyways, coming back to the floor now I want to do is again go to the action browser in physics, let's do a coalition event and, uh, removed this event. We're not using it. Estate one on collision enter. And if the collider, if the other objectors ball, if the other object has a ball tag, then you send the event hit ball and we're gonna add that even here and it's gonna go to this state. Um, I'm gonna call this okay, I've seen status Congress, that scene. So when or hits does object? The four object gonna restart the scene. So in this restart, seen stayed click on your action browser and that C should be under level and we're just gonna go restart level. Okay, so that's straightforward. If the ball has the floor when you start the level, see if that works, Let's give it a try. Deploy. And now I'm gonna intentionally miss the ball, OK? I don't know if you catch that, but as soon as the ball has the floor might be a bit easier to see it from the scene. So whenever the ball has the floor, we restart city, so feels pretty good. Now I think we've got most of the basic gameplay elements in there, so that's great. And I think with my next in the next video, I looked a little bit more. Maybe some sound facts, some particle facts or what? Not using what we've learned in the previous ways. 7. Parent / Child Objects, Random Color: before we start adding new things to game, that's, um, I want to organize the scene a little bit the hierarchy just because we have so many objects here and it's getting a little bit Messi. So one quick way of organizing your scene is by using empty game object and this concept of parent and child objects so that that's let me just quickly demonstrate that. So let's go to came, object and click on, Create empty and then we have an empty game object here. I'm, as always, I always to reset the position, and I'm gonna call those on the score bars or on the score group boys course. Okay. And the reason why I started with an underscore is because it would just help with sorting . As you can see in the hierarchy, it's sorted alphabet alphabetically, so if you have been on the score, it will tend Teoh show up first, and I'm going to select all the bar of germs and track them into the good bars. Object. Now you can see that they're all inside this group. Boris. Subject. Now, Now you can call this the parent object and everything inside of it is a child object so you can collapse the parent object. And then there's you won't see the child object. And that's one where you can quickly clean up your seen a little bit. So I'm going to do that for for the other object. It's wrong. I'm gonna call this one, um, bounty. So I presupposition I'm gonna print all four of the boundaries into this parents object again. Parent object. And these are the child objects inside his parent object. Now, the cool thing about using parenting right, which is basically creating a parent object and putting these child objects in them, as look at this will not. When I click and select the parent object, all the child objects are selected so you can do cause things like move. If you move the position off, the parent object moves everything inside of it. I said news. All the child objects inside of this parent object. When you rotate it, see that it's rotating the entire Goob instead of let's say, if I just click on one, which will take that one, and even if I click on all of them, um before five locals like that, that's going to rotate? No, I don't take individually. But, um if you click on just one of them for any one of them Sunday, there are gonna reltec differently. But if you group them together on the parent object, you can manipulate them all at the same time. Now, this is important down the line when you have complex objects that requires different components and different sort of ways to manipulate it. And you might want to start using that mechanism, the child in parenting mechanism. We're not using that just yet, So we'll leave that for another topic. But for now, just understand that you can create parent objects to group your child objects together so you clean up the scene, so that's the first benefit. And the second benefit is you can manipulate them all together, right? So I can move can really take this entire scene all together. Now imagine if you have a interaction that changes everything inside this, Uh, that's a if you have on interaction where it's shakes, this coop bars, object, this parent object, Then it was shaped the entire thing, and we can create some sort of pretty cool effect like that So that's that's parenting. So we've done that now. The next thing I want to do is I want to have a bit of color for these boys, and I want them to be randomized. So let's go back to the pre flaps. Right? And then click on the boy Prefab. And again, Let's go to play maker. Uh, sometimes it doesn't show up. Just click on at it, and it should show. Okay, make sure this is the prefab. Okay, so right now it's just an idle state collision in tow. Destroys itself, changes destroying, just so that self explanatory. Now I want to make it so that whenever the game starts, it will go and peck one of the few colors that I've defined so that each one of them can have a different color, or some of them will have to same color, but they won't hold with the same. So I'm going to add a new state, and I'm gonna call this in their shoulder vacation. Right? And I want this to be the first state right, so set as start state. So when the game starts, is gonna come to your first, and we're gonna do a few actions in a and then afterwards, when it finishes would go to idle state. Okay, Action browser. See what we can do with color. Right? So there is an action called set Random color. So that's great. That's some What this will do is there was sent around in color to your object, Right? So let's track that in, and you need to store this color somewhere, right? So basically, it would pick one of the three or heart, however many colors you want and store it in a color variable. So we need to first create a variable for the color. So we're just going to say are colder, right? So that's gonna be our color variable. Okay, I didn't make this a little bit bigger, so let's say everyone five different colors to choose from, and here you can just select different colors. All right, you could just do that. Just gonna pick a few random ones, okay? Now make sure the white is the same, so make them all one, so that would give them unequal chance. Um, Teoh be picked if you click on the help button. Daniel, explain to you what it does. It's always get Teoh to review this. So conceit. The relative weight off this color for the wait, right? So that's good. Um, and then we're gonna store color into this color variable. All right, so that's good. Now let's just quickly play and see what this means, right? What does this it play? It's gonna take a bit of time. Okay, now it's Pause it for a second. Open up the barn group and just select. Let's select the first part, and that's checked. Variable now, the first in the first part at the variable the color variable. The bar caller variable has the color red on. See the 2nd 1 has to color yellow. 3rd 1 red again 4th 1 yellow again. 51. It's purplish color, so we can see that now. This color variable is different for each bar, just as we want it right. So when it's initialized in the initialization, state would pick a color for that color in the color variable, that terrible that contained and we talked about. Okay, great. Now I don't just want to pick a color. I actually want to change the look in the game, so let's go back to materials. Sorry. Go back to action browser. And what I want to do is said material color and great. It's it's right here. Or if you don't use search, you could go to material set material color. Right. So we're gonna drag this in here, make sure that we do that after the colors of f selected. All right, I'm gonna collapse this and, uh, use your own that we're gonna chance. Oh, and I just made a mistake here. That's back up a bit. Now, see that I'm making changes to this subject, which is not good, because none of the other ones will have the change I've just made. See, It doesn't have the event. So I'm gonna back off. Actually, I'm gonna revert, which means I'm gonna revert this subject back to the prefab. So be exactly like what? The prefab ISS. You can see that now it's removed that action that I've just added, right? So they're not all the same again. Make sure we got back to the project. Click on the prefab and make changes to this one. Or if you're in playmaker, click on prefab these dens and click on select pre fat. Now we're working with the prefab here. Okay, Now again, extra browser material. Set material color and put it down here. Okay. And use their only we're gonna change the color off this particular object itself. And don't worry about these for now. And the name color color. Instead of choosing and color here, we're gonna use the color variable. So it's going to set the color as the color that was picked from here. Right? Okay, that's that. You were safe and, uh, trying out. Okay, so we can see that now. We have different colors on, um, in our object, and every time the game resets is going to give you a different color. So every time we start the game, since it's randomized, you have a different You have a chance of one in five chance of getting it different color , right. Five different colors to choose from. Not the most amazing color palette. But you get the idea. So that's kind of fun. Save again. What's the next thing we can do? We can't at some sound effects. Right? So we've used sound effects before. Um, so let's try that again. I think that would be would be pretty fun 8. Sound Effects: Okay, So in my current project, I don't I don't have any sound have any sound effects. So So let's go back to our trusted asset story. And I remember we used that a bit sound before, and maybe we'll try that again in their work. Very well for this game. So audio. So what we have here, Durant, there? If I could find that one again, maybe I'll just, uh, just a bit sound. Was it this one? There was this one free pack, right? So that's important. And you fill it familiar with this process now? Okay, that was quick to have a bit sound. That's preview some of these dramatic. It's too much. Sure, Maybe it Okay, that's just use that one many to could have work. So what we want to do is, whenever the the ball heads something we're gonna change, we're gonna create a sound. So So we're gonna put this on the the ball object. I'm going to change the name back to ball is round. Thing is, it's quite city. Okay, so go to play maker. Can't make sure this is the right statements, you know you're looking at and what we want to do is simply when you hit something, make a sound right. So we're gonna go to the flip y event and and sound. I like the sound, right. Just go audio. Ah, deal. Play place. The sound group said Yeah. So I think this will work What some of the other options do. Let's just use this. The audio play with wood look will move it to the top before it goes to the different events. Right? So now it says game object requires audio source component. Right? So what do you think? Simply click to add that. And now its added Here. Remember we when we set up sound events earlier Sound sources earlier last week, we added this manually from the component at Component button here. But with play, maybe you can just click on that warning. And from after you do that for you and here again, I'm going to just drag this, get in here, right? And we don't want it to play on the wake because if we have play on wake every time they came stars, it's gonna play once, right? So that said some this uncheck that and another thing I want to do is I don't want this to be a three D sounds, right. I don't only care about the position, Mr Ball Relative to the camera, which is where the listener is so unchecked through the sound and just apply. Okay, so now it's a to descend to go back to the ball and see, we have here time so that your work, Quicken playmaker And, uh, I could just do that. I should another way to do this. That's just remove that for now. Uh, because I want to show you that the other thing that you can do And to do this, I need to move this somewhere else. Okay, Now, again, we have the audio play action, and I'm going to simply drag the ordeal here. So play this particular sound. It's fine if if you don't have this define will play whatever is here. But if you have this defining play, this sound instead. And the nice thing about defining the sound here is you can in different states, you can use a different sound, and that that's quite nice. And then we don't care about finished events, so leave that this is come in with us back. Okay, See? See how that quips play get. So now whenever it hits anything that's not a wall, because remember, we for the wall. We have a different state handle that so we can see what? Copy this, but here is where also, when it hits the wall, play a sound. Okay, some sound. That's good. Okay, Now, the next thing I want to do is when the ball heads the floor, let's play another sound, some sort of game over sound. And then will we start the the game? Right. So we want to go to four. Sorry on this thing here, and instead of simply starting the scene, I'm gonna add a state here says play down. Right. So instead of going directly to restart seeing, I'm going to go play sound and then I just finished state for the sound finishes playing will go to the finish state and then restart. And something I'm gonna do. Do you play? And it's again going Tell me that I'm missing a on Nodia stories component, and I just click on a c was automatically. This is what I'm thinking. And this for you. It just Great. Now we just need to find a sound that sounds like a game over Crashdown might be. Have you good luck? Some sort of explosion. Okay, that that's give, like that one. So, again, I don't want it to be a 30 sound, so check that apply. Click on the floor again. Find your state machine. Right. It's here. So now I'm gonna use a different method to find that, um, file at the asset. So just click on the circle button here. And when we wanted to use waas, I believe it was explosions. Three. Yeah, I'm gonna now it's exploding three. Um, you're not sure. Click on that for a select explosion. Three. I think that's that's what we want. Now, one more thing. If we don't define a Finnish defence, it's gonna go from the state. When the ball hurts the floor, come to this state, try to play this sound, but immediately go to finished and then restart. So the scene is going to restart before we even finished playing that sound. So I want to make sure that would go to the finish event only when the sound is finished. Right. So we define the finished event here. Finished. Let's play and give it a test. Okay. See, that's the problem that I was trying to avoid When, uh when I said to use the finished event One potential problem is the finished event might get my start without finishing the sound right. So just because the system, it's it's finished state, Which means once you go once you run through all the actions here but what America run. So let's see if defining a different van, we were using a custom event. Maybe that will work, always go different and finished audio and also change this to a finished deal. So that's see if that helps. Okay, now, intentionally losing. And that didn't help interesting me enough. And I think the problem here is the system doesn't know how long this audio clip is. So it simply goes, Well, we're gonna play this, and then we're just gonna go finished. Um, so that's that's not ideal. Well, we can do is we're gonna go get rid of that event going to stop the event. I'm gonna get rid of the finished audio. Swell us. We're not using that. What we can do here as what just used what we had before were used to wait action and we'll just say, Wait for a period of time and then finish the event right O r go to certain event. So that's at back finished event and we'll say Have Teoh period of time. Now we need to know how long this sound as it was this one. I was just really short. So we're just gonna dio maybe 0.3 seconds real time. Try that so you can see that it's playing a little bit longer. But then we need me to wait a little bit longer. So finished. Maybe just one second my work. Try that. Of course. The problem is, while the state is waiting for the sound to finish, the game is still running. Still control. There's the ball. It's still moving, which is not ideal. So what we can do? Let's see if we contrive this so I think we can. That's try using this thing called scale, time, time scale. So secret is time, right? So the idea of scaling time might be a little bit abstract, but basically think of time as just another variable, right? So when time is set to one. That's normal time. That means that the game is running a normal speed. If you set skill time to than the game runs twice as fast. Just imagine if you playing um um, Sonic son is the hedge would pick up an island that speeds up the game twice as fast. I don't think there's such an item in the game, but imagine if there is, or you can slow down to the time off again. Slowed down the entire speed of the game by reducing the time scale 2.5 than that you run. That game is running at half speed, and cool thing you can do this is, if you said skill time. If he's skilled. Time 20 said the time scale to zero. It practically pauses the game right, and that's what we want. We want the game to pause when were playing that sound and then we restore. So that's that's at that action and you won't do this before you start waiting, right? I think that that would be better. Um and then that's just dragged us down to zero. So play this sound and, um, reduced time scale to zero, and we want to make sure that this waiting is really time. So it ignores game time because we're passing the game time here. But this will continue to to count. All right, so that's just quickly. See this real time. You know what? Time scale Useful If the game is Paul's rice and make sure we have that checked. Okay? Safe. And it's play right. Paused the game. And now the problem is, when I restored the game, the game is still paused because the time scale is still zero. So we want to make sure that we reset it. So click on times Skill time copied at Pace it here. And we're gonna reset it before we start the level. Right? Okay. Say that. I think that would. That should fix it. Consistency. Right now. Way we have the game is back running. Okay, good. Okay. So I forgot to do one thing which is restricting the movement off the player boy. Right? Right now, you can just keep moving, keep moving outside, off the boundaries. Just play. It can see that keep going left, and it's gonna go out. The theme, which is not not ideal. So So that's That's 9. Player Control (Part 2): Okay, so let's to make sure that the player poor doesn't go out of bounds for us. We don't want to play it to be able to move to blow it all the way out of scene. Right? That wouldn't be very fun. So I think that the first thing we want to figure out is, um, just recent this to be around. Okay. First thing we need to know as well. How far do you want a player to get? Right? So let me just look at this from this back angle. Make sure it's own neo Ortho graphically and just, uh, it's just kind of visually, I it So this is probably that closes to left. We want the player to be able to go, and it's roughly about negative. 15 on the X axis. So negative 15. It's just remember that number, Okay. And let's go to the other side. 15. And this side supposes 19. I think we're allowed to play to go into it a little bit. 19 19 15. That's fine. Okay, so between ex uh, between negative 15 in 19. That's that's the exposition when they restrict this boy too. Okay. Now, um, Let's go to the state machine for the player boy and we've got to control here and I'm not gonna touch them. Except I'm going to change the space from self to wear out. It doesn't make a difference right now, but it's good to keep that consistent because I am going to be using world space now, okay, And think about this. So basically what we need to do is we want to tell the system, have the exposition off this object as greater than think. If, well is smaller than active 15 then we want to reset it back to 50. Negative. 15. And if the position is bigger than 19 for you don't point. Now it's 21. We want to make sure that we, uh, moved back to 19. We don't want to do to go over right. So that's the basic idea. That's what we're gonna do here. So, first to best define eso event, right? So that's, say experts. Too small, actually, that's used low case X accidents and leaving his experts to all right. You might not need to, but I like to keep things. It was separate. Okay, so we'll have these two events. X is too small access to big. And then what do we do when when the exposition is to Baker. Too small, we wonder. Reset. Thanks. Right. So that's the state. And once we way said it, we're gonna go back to the move movement, state the ones our job is done here. We can go back to the way things are. Okay, so that's that's the basic set up. Let's go into the actions. Right. So here, first thing I want to do is I want to find the location off this boy the current location. Whenever the game is running. I need that information. So it's got variables defining variable called explosion. That's the variable that's gonna hold that information for me. And, uh, let's go actions and get position. Now, this action will allow you to convert your current position to a variable. It was signed that value to your variable. So get position, and all we care about is the axe variable expedition. So I'm gonna save acts two x position, and I want to make sure that we do this every frame. So you know, we don't just want to do this ones We want to get the current position of the object, right? So I wanted to run every frame. And as you can see, I'm sending Institute of World Space, something here just, you know, we want to make sure it's consistent in this case. Can. Now I have the exposition and the next thing I need to do is compare this exposition to the boundaries, the numbers we just discovered to see if it's too big or too small, right? So let's go to go back to action. Brown's it and we're going toe to do afloat. A float Compare. Okay, here a full compared basically compares the float variable which in this case is exposition to another number. And we've discovered that we don't want it to go speak smaller than negative 15. So we put in a good 15 down there. And what do we want to do when the exposition is smaller than negative? 15. So the flow compared. You can use this to send different events, depending on the if these numbers are equal or if the 2nd 1 is less than the 1st 1 or if the 2nd 1 is greater than the 1st 1 now, in this case, we want to check when the exposition is smaller than negative 15. Then I think the access to small right. That's when the object is way too, too far to the left. So we're gonna send access to small event. Okay? And we want to check that every frame. A swell. Okay, so that's that's what that's how it is. Find out if it's to your small would do the same thing. Float, compare hair. And in this case, something would compare Exposition to was the number of 19. I believe so to the right side, this 19. And if it's too big, send the X is too big event. So when exposition is greater than 19% the access to big event It's good. When the exposition is less than negative 15 we send the accidents too small. You're right. Now I'm gonna make sure this is running every frame as well. Okay, so let's just give it a quick test just to see that the these events are working. I am going Teoh disabled a bowl now because if we don't catch the boys going to restore the game and it's going to affect the way we tested, so I'm just disabling the ball for now. Just I just want to test this. Okay, let's play, okay? And we're in this movement. Stayed just waiting for him to move the object. So it's moving, and we can see that the exposition that variable exposition as changing and is matching the number here. Right, So you get position. We are wrapping this x position and assigning that Number two, this variable here. Right. Okay, so that's working its good. And right now we're at naked five, which is still bigger than negative. 15. So, kid, to keep moving to see what happens when we go to any of 15. And it's the program is crashing. Why? Because I have accidentally created an infinite Luke now an infinite loop as, um, basically describing a situation where the crop, the program is stuck doing the same things over and over and over again. And that's not cool. Now, M playmaker, it stops you from doing that. But let me just explain what just happened. That's stop the game. So from here I have one. The exposition is smaller. Negative. 15. We're gonna go to reset X and there's nothing here. So it directly goes to the finished event, which constant comes back to the movement state. And since we haven't done anything to change the exposition, the exposition is was still smaller. Then they give 15. So it's sense the event back Teoh sends us back to the reset ex state, which then finished the stating sentence Back to movement. So you can see that system just continues to send us back and forth between these two, and there's no way to get out of it because it's we're not making changes. So that's let's delete this transition to avoid that infinite loop. And as you can see, Playmaker tells you possible infinite loop. So it sort of stops you from from getting into this infinite loop. Usually, when you have anything new, you have to restart unity because the system just doesn't know what to do with this off. It's just keep repeating the same things. Okay, anyway, so let's remove that event. So we we just want to know that one X is too big or too small. Is it actually going to go to this state? Try that again. Okay, It's a movement that's good. Um, see that again. Variable matching value here And when it goes to Because 15. Right, So it's the position is less than a good 15. Run it. It goes to the exits to small event and sensitive to the reset X state, which is what we wanted. So I'm gonna do the same test on the right hand side as well, just to make sure that we've got that covered. So I'm gonna collapse this, which is going to look at this action here. Right? So Okay, I'm moving to the right. The position is increasing on the X Texas. Okay. Going close to 19. And as soon as I hit 19 As soon as I get bigger than 19 goes to the state. Okay, great. That's what we want it se. So in reset exposition reset. Ex state. What want to do is we want to reset it. So we want to reset the exposition to in between negative 15 and 19 so it doesn't go over the walls. So there is a very handy action here. It's good action, ground float. Actually, that son, let's go to the math section. And then there are a whole bunch of actions related to math that we use, and the one that we're most interested in is called float Clamp Look, Camp claimed. Now, it says, claims the value of float bearable to a minimum and maximum range. So the great thing about this is you can check your variable and see if the value is in between two numbers. And if it's not, then this action wolf said it to the closest value off the two. So we want the minimum. That would be negative 15 and the maximum barely to be 19 right? That's the boundary, the value of the two boundaries we found out. So if exposition is less than negative, 15 is going to automatically reset it to make 15. If exposition is bigger than the max value here, that's safe. Exposition is 20. Then this action will set it back to 19. So that's really handy Now, that's not all we want to do, because once we reset the position to in between these two numbers, we want to apply that new position to the object, right? So if we just do this all right, see? No, it's OK. We have I'm gonna keep when we left. Okay, Now you can see that we went past negative 15. So we were at negative 15.35 and we went to the state. It resets the X position, the variable exposition, which is this variable here, but would need to apply this new value back to the position off the object, because right now it's just a number of stored in this container in this position. But other than that, it's not actually doing it us any good because it's not applied to the object. So that's do exactly that set position, and that's grabbed the exposition and apply it to the actual acts here. Right? Remember, this cacs position is a variable inside. Put the state machine, and we need to apply this number to this. Here, then, is the world. Coordinate, Kourtney. And that's it. That's ad of Finnish state to go back. So once we reset the position, then you are allowed to move the born again safe. Thank you. That quick test. Okay, now moving left. You can see that as soon as I had 15. It's gonna stop. It's gonna reset my position to 15. Because I have this so clamped there. Now I could keep moving to the right and again when I hit that number is going to stop me from moving any further. That's good. That's how we limit the movement off the playing. Now let's enable the ball again and just give it play half disabled game audio for you just because I want. I don't want to distract you, but you can't move there and anything that the games thumb. It's looking pretty good happy with this. 10. Create Object (instantiation), Particle Effects: Okay, so that's good. We have the basic game pretty much finished. Right? So this is essentially a prototype of a prototype for break out. You can play it. You can feel how the gameplay experiences like and I'm gonna make me dio a little bit of just adding some effects, making it a little more fun. Now, we've added some random number colors to these bars, which is cool. What else can we do? Um, so let's see, that's that's have some sort of particle effect. Nothing that would be cool. When when the ball hits player boy or anything. Then when there is any sort of collision between all and any bars, we have a little party go effect. And last week we quickly talked about particle effects. I'm gonna go back to asset store and grab those unity particle effects again. Right? So here, if I can find them in, and it's always when I try to find something I could never find them. So I'm just gonna do a set of unity part, of course. And I still can't find him funny. The name. Yeah. Sorry about that. That's so trying it again. Effects. Miss your friends. I expected to see only three of facts in the story. Andi, I can't find it. Oh, wait. It sort of that. Okay. Simple particle packed. I put this. Yeah, putting assets. I'm just gonna let it do its thing. Let's close it. And we have to particle effects here. Yes, you can see when you go to resource is and different photos, you can see there hope under pre fabs. And just like how we created these pre far pre facts, this asset that we've downloaded it also has thes pre fabs, basically pre created game objects that can be re used repeatedly. So, um, it's just, uh, choice and random one explosions, flares. Try that. Kumble. What does that look like? Okay. Okay, So it's got that effect there, and it's got something else. Yeah, Okay, maybe a bit too complicated. That's just try something simple. Yeah, that might be fun. A multicolored. Um, it's kind of interesting, but maybe that's try a explosion. I think that might be a bit more more fitting for us. Okay, that's good. So let's just use the burst. Um, that deleted. Just remember, it's here under a simple particle packed resource is explosions go back, Teoh the bull object, right? And good play maker. What we want to do is simply add something here. So again, when it hits, boy, when it hits anything other than the wall, it's gonna come to the state. And I'm just going to say, What can we do? Yeah, um, this is this is probably not the best way to do it, But this will work for now, Create object. So the create object action will simply create an object in the scene. So something that's not currently in the scene. But it just created for you and want to hear is we want to find that object first. Right? Wrist. Now you have to create when you notice that everything here is a prefab, you can have Teoh. Basically, you have Teoh pick a prefab for the game object that you want to create. So, uh, burst is the 11 So that's six like that spawned point. Odds just I don't think we need to work out that, um the one thing I you do is I'll just drag this drag your player, not the players air the owner of the object going to spawn points. I don't think that's necessary, but let's just go with that. And don't about the rest. That's CM. Let's see if that works. Right? So wanted hits an object. It will just create that particle effect. So that that works really well, right? So it's got, like, a little bit of with effect, which we want it now, the problem. However, if if we take a leg, I'm gonna cost the game second. Okay? We have thes things that just stays in scene. So that's that's not idea, is it? But we don't want to keep having these effects staying in the seat. So what I am going to do as I'm going to copy this first prefab put it in my own 35 floated . I don't think I could just copy it that way. So I'm gonna good control de duplicated, but in the flaps. And I'm gonna choose name too first. Self, right? Why do you want to do that? Because I wanna add a playmaker component to it. That's going to destroy herself after after a short while. So it's simple play make a script. This is, uh Let's go here. Okay. we got the first self destroy. And so it's going to do is wait and then destroy itself, right? We refuse, destroyed So before And so that's same and same action. And we also used with await action for it. So that's yeah, we're gonna use real time as well. Probably doesn't matter that. It's just I think, um, I don't I don't really need another action. What I need now is a finished defend that connects to the destroy itself state. And, uh, how long was that particle? In fact, it was about maybe half a second. Let's just five, and it's go back to the ball and make sure that we are creating that new prefect that I just created. I prefer us first self destroy that one. Okay, so that's give it a run. So if you pay attention to the hierarchy, you see that the the fact object would disappear have to have a second. So that's good. That sort of keeps this scene clean, right? So So that's pretty cool. Now, another thing I'm my want ad is I want the camera shake a little bit. Something happens. I think that might be fun. So I'm gonna do that in the next video because there's another topic I want to quickly mention 11. iTween Shake, Orthographic View: so so far, we've been using Playmaker to create interactions for the object that the playmaker component is attached to, right. So we use the playmaker on the player board to control the player board, refused the component, the player, the playmaker on the ball to control everything that's related to it and something with all the bars. Now you can also use playmaker actions to manipulate other objects that's not directly attached to the The statement is not directly attached to So what I want now as having still a fact that with just created it's cool. And I want to shake the camera a little bit. When we hit something that where the ball had something, I want to shake the camera. So go to action browser and we're gonna find a shake event now. Oh, this is a good time to talk about between a little bit, uh, where did it get? You can find this category called between. And these are really nice animation that you can use in terms of when I say information. I mean ways for the objective move to rotate to scale, and there a lot of options you can use in these actions Really cool tool. Ah, a little bit more complicated if you're not familiar with it. But you can always click on the help, but and I think I don't have Internet connection over certain, but then you can find out more vitamins. But for now, we're just gonna use the shake action. Right? So we're gonna find the I I Tween shake position and drank it into this state again. And the game object instead of using player, owner or you instead of used owner that specify came object. Right, And that's tracked the main camera here. So we're using a camera vector. We're just going to define yeah, shaking. Which sort of which direction we wanted to shake. Ah, that's just dio pax in line that will be corrected. Really? How long do you want to shake the point? Three seconds and let's see how that looks. I don't think we need to touch anything else, but I might be wrong. So let's give it a test. Right? So the camera is not shaking. What's wrong here? Kind of a trick. The ball shake position. Uh, OK, interesting. If we just put it pick number there. That day. I think the problem was we don't want Teoh way. Don't want it to stop on accident. What that's means it will stop whatever this is doing when you move to the next state when you leave state and this state doesn't actually taste take very long to finish everything public finishing a friend too. So I'm gonna uncheck that I 10. I see that face fixes it. So if that fixes it right here, yeah, to have better for camera movement here? Uh, probably too much shaking on seven. Just gonna change that back to one and three now. So again, the problem was because we had this stop on exit checked. If you have this, check that as soon as you leave, the state is going to stop this. Ah, between animation. So OK, so that's, uh, trying to sitting a bit dramatic, but it's kind of got to effect for us. Might get knowing when they saw the ball was hitting everything sudden. So, um, you get the idea Very cool. Um, one more thing play makes going. I'm gonna enable I'm gonna say troll did stop that troll active label because, uh, when I don't have that, then in the game, you won't have the those tax that not showing it. You won't have the text that's showing the the state and, uh, see, that's funny. Nerve ball sort of went through the wall. So, uh, so? So there is a bug somewhere here. If if we're not care for the wall could go through in between these two things so could quickly fixed that. Why, Um, that's not worry about that for now. I think we otherwise, there are various ways we could fix it. But for now we have the basic game structure created if the prototype fairly fairly done and have some sound effects, visual effects and, as always, some bugs in the game and fixing bugs. Always a long process. So let's let's give that a try again. Actually, um, I think we've played the game, and if so, you don't need to see it running again. One last thing I want to mention before before I wrap up for this weight as the idea of a three D game and versus a two game right. So in this scene, you can see that, um, things that are further way are smaller, right? So let's say this wall, it's that same length on this side and on the other side. But in the scene in the game, you can see that it's on its smaller towards the end because you have the perspective v on the camera. Um, if you want this to look more to D than three d, then you can simply change the projection on the camera. From perspective to Ortho Graphic. Right now you have to make some changes when you you switched between the two. So we're going to change the size, too. Something that lost smaller. Some like that. Maybe gonna do 20 soon. Now, this is flat V with flattened the camera view. So when you play, it looks a lot more. It looks a lot more to day than three D Now, right? We don't have the depth that we had from before when we had the when we had the perspective be If I run this often, this is very, very much a treaty game. Everything is just thought, which is cool, which is very cool. A lot of times he just wanted have a to d. So the layout to the visual, and I think this will work really well. So basically, whenever you want to de game, you change this to author graphic and, uh, that the game was off a sudden flat. Now, of course, you're you're gonna have to deal with animations differently. Um, and certain other things that you have to take into consideration. But that was always That's always the first step is manipulating this option here on the camera. So I've been changing back to perspective. I quite like what we had going before. So there you have it. That's with three with created break out. And, uh, I believe you to create this. You know, you can at all sorts of facts, acting directions and just go crazy with it and see what you can come up with. So have fun and office our as on Monday, the fourth our belief in the afternoon. So if you don't have time or if you missed it, we're going to record it anyway. So you'll have that video as well. So great, then I will talk to you guys later.