Unity Game Course: Brick Breaker 3D | Octo Man | Skillshare

Unity Game Course: Brick Breaker 3D

Octo Man, Let's make your dream game a reality!!

Unity Game Course: Brick Breaker 3D

Octo Man, Let's make your dream game a reality!!

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
72 Lessons (10h 4m)
    • 1. #1 Introduction

    • 2. #2 The Concept

    • 3. #3 Unity Setup

    • 4. #4 Import & Paddle Setup

    • 5. #5 Paddle Movement

    • 6. #6 Playfield Setup

    • 7. #7 Automatic Border Setup 1

    • 8. #8 Automatic Border Setup 2

    • 9. #9 Automatic Border Setup 3

    • 10. #10 Ball Setup

    • 11. #11 Ball on Paddle Reaction

    • 12. #12 Resizing the Paddle

    • 13. #13 Exposing Resize Parameter

    • 14. #14 Brick Setup

    • 15. #15 Brick Script 1

    • 16. #16 Destroying Bricks

    • 17. #17 Creating New Balls

    • 18. #18 Releasing New Ball

    • 19. #19 Tracking Bricks

    • 20. #20 Lifes 1

    • 21. #21 Reducing Lifes

    • 22. #22 Reset Paddle Position

    • 23. #23 Quick Recap

    • 24. #24 Score Manager

    • 25. #25 UI & Show Score

    • 26. #26 Show Lifes

    • 27. #27 Intro Level Designer

    • 28. #28 Scriptable Object Level

    • 29. #29 Connection to Level

    • 30. #30 Grid Size Check

    • 31. #31 Input and Error Handling

    • 32. #32 Creating the Grid

    • 33. #33 Display The Grid

    • 34. #34 Display Grid In Scene

    • 35. #35 Headers

    • 36. #36 Brick Sets

    • 37. #37 Level Designer Final

    • 38. #38 Ball Start Direction

    • 39. #39 Power Up Prefabs

    • 40. #40 Power Up Manager

    • 41. #41 Spawning Power Ups

    • 42. #42 Power Up Rotation Fix

    • 43. #43 Catching Power Ups

    • 44. #44 Multiball 1

    • 45. #45 Multiball 2

    • 46. #46 Multiball 3

    • 47. #47 Paddle Extent 1

    • 48. #48 Paddle Extent 2

    • 49. #49 Prevent Paddle Push

    • 50. #50 Laser Shot 1

    • 51. #51 Laser Shot 2

    • 52. #52 Laser Shot 3

    • 53. #53 Prevent Ball Leaving Screen

    • 54. #54 User Interface

    • 55. #55 Lifes UI

    • 56. #56 Environment Particles

    • 57. #57 Environment Background

    • 58. #58 Animate Background UV

    • 59. #59 Explosion Effect

    • 60. #60 Create Explosions

    • 61. #61 More Environment Particles

    • 62. #62 Ball Trail

    • 63. #63 Assertation Unity Bug

    • 64. #64 Level Loader UI Layout

    • 65. #65 Level Loader Script

    • 66. #66 Level Button Script

    • 67. #67 Level Loader Script Final

    • 68. #68 Setup More Levels

    • 69. #69 Win and Lose Panel UI

    • 70. #70 Win and Lose Panel Setup

    • 71. #71 Using the Panels

    • 72. #72 Final Steps and Conclusion

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

In this Course you'll learn how to create a Break Out / Arcanoid / Brick Breaker 3D with Unity Engine. Those type of games are quite popular since the 1980s. I will show you step by step how you can create Brick Breaker 3D.

This course is a Beginner/Intermediate course, so if you have trouble in any case, write me a message or Q&A, and i'll help as best as i can.

If you are beginner, you might have some trouble to follow, but the videos will guide you through the complete course. Don't forget: You only become better if you repeat things and keep on learning!

So we create Systems which will give us the freedom to:

C# (Monodevelop)

  • A level create system to create our own playfield by simple settings

  • Editor Scripting (Intermediate Topic)

  • Automatic Borders which holds the balls and paddle in any screen resolution

  • Physics which handle all ball movement

Unity (2019.3)

  • we create a playfield

  • we create a GameManager

  • we create a Level Loader

  • we create objects to create quick and fast levels (Intermediate Topic)

Course Material

I provide the following Material with the Course:

  1. 1x Brick 3D Model

  2. 1x Background 3D Model

  3. several 2D Graphics and Masks

  4. You have to write the code on your own, i do not provide the final scripts!

All other graphics for Menu's, Icons, Images or Buttons need to be created on your own.
All Materials i provide are for education only and should not be in your final release!


In the end of this course you will have a fully functional Break Out / Arcanoid / Brick Breaker 3D Game.

So what are you waiting for?

Let's make your dream game a reality!!

Level: Beginner
Video Course Length: ~10 hours 
Unity Version required: 5.3+

Meet Your Teacher

Teacher Profile Image

Octo Man

Let's make your dream game a reality!!


Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.



1. #1 Introduction: Hello and welcome to the course. My name is Aquaman and I'm your instructor for the next couple of hours in now to create a brick breaker 3D game. In Unity engine, we are going to learn how to create some user interface, or literally setting up this user interface. We're going to take a look and to score as well as life's. We're gonna take a look into pebble movements so we can literally move the pedal left and right. We're gonna take a look in some little facts like some particle, thanks and all the other stuff. We're going to create a scriptable object, a system in which we can super simply design different designs of types of levels. So in which like the system itself is going to automatically create the bricks for us and tint them if we want them to be tended just by using a simple setting of a here we are going to take a look into those gizmo so we can see where all of this going to be created and how huge this gizmos have to be. So be prepared for a rather advanced session of the day as well based on this editor scripting possibilities to make our life easier, This is an unnecessary step. We'll simplify the process whenever we go and design design even bigger and yeah, much more intense levels with different bricks and all the other stuff. So speaking of pedal, we're going to take a look into one specific possibility to keep the pedal in screen space so we are unable to leave it. Same for the both. They are going to literally do the same with the Space key. We are shooting the ball and we of course, having a possibility to give some different bricks over here into the game. Also, there is a possibility or a drop chance to create multiples. We have an extension for the pedal itself and we are going to get some speedup and so on and so forth. Once we are done with all of them, we are also able to suit with a laser pickup, which is the l pill over here in which we are able to suit down all of the bricks overall, as well as we are able to lose alive. We are able to win this game. And we are going to be able to get score. We have the possibility to restart the game or even go back to a menu. And we are going to look at how we can literally automator which levels and buttons, corresponding buttons for this particular levels to load. So the one you have seen was the first one. We are also all I was creating a second one just by copy and paste. It looks a bit different right now, so we have something to take a look at. I have a complete different design over here just by using some numbers which I had to pass in. And I can literally do as much different numbers. I want to have the same possibilities of a here, we can again design the drop chance over a drop manager or drop or power up Manager, which gets or takes care of how much chance we do have to make sure that we get any kind of a drop. Also, we are taking a look into all this physics over here. So what do we really need to do some physics? How does the multiple functionality work, as well as the extension parameters we're going to learn about coroutines. We are going to learn about, yeah, literally functions, different classes and all the other good stuff. Everything we need to create a brick breaker game at all in the 3D space over here. So if you liked this topic of here, I just wish to see you on or inside the course. So just join me on my session inside the course. And let's start learning into how we can create our own brick breaker 3D game in Unity. I hope you enjoyed this, will preview and see you in the course. Bye-bye. 2. #2 The Concept: Hello, ladies and gentlemen, boys and girls. My name is Dr. Mann and I'm your instructor in the next couple of hours in how to create a brick Brinker 3D game in Unity. Brick breaker in the paths also was known as aren't glenoid. And this game was played on Atari and some other consoles. And I'm actually video consoles or video game consoles, as well as on the PC. And currently there are even some on the VU, I guess, as well as on PlayStation four and so on and so forth. This is the concept videos. So we are going to talk about what is art and what is brick breaker, what is the goal and what is going on in the game, as well as we are talking about what we need to create a game like that, as well as we go into some little details here and there. So you get an idea about what this course is going to be about as well. So first off, this is kind of the end result we are going to see later on. That is like where are we going to have a pedal on the bottom, which is going to be the penalty for which we can move left and right. And then we have a ball which is going to be the ball which has to be brought to all the bricks and the top, as well as we need to make sure that the ball, whenever it hits the bricks, it's going to reduce their health. And whenever the house is down to 0, that brick is destroyed and wants the brick is destroyed, we get some score. If all the bricks are destroyed, we are basically done with the level. So we have won this particular level. We can, if we want to own lose all on wind, doesn't matter. We can save the score later on as we want to or if we want to give some out some stars or maybe we can also look up some time into it and so on and so forth. Also, we are going to have a text over there which we can feel like manually or automatically depends on how we are going to create those systems later on in which we just say, okay, this is level one of 1000 or whatever. Also we have some health or basically some life's. So whenever the read the little ball hits the little red bar at the bottom, which is going to be the debt trigger zone. Literally, whenever that hits the trigger zone, then we lose a life because we are unable to play the ball anymore. And we are going to get a new one as long as we have more lives or enough lives left. The ball will also actually collide with the, with the border of the screen. So we are going to take a look into this a bit deeper late on, depending on whatever the resolution of your screen's going to be, we want to have something which is automatically going to protect the ball to not leave the screen. So no matter whatever it is, landscape mode or if it is a portrait mode, doesn't matter if it is on Android and it doesn't matter on PC. All of that doesn't matter at all. We just want to make sure that the ball is unable to leave the screen except on the bottom part and do it through the dead zone over there. So that is basically everything. So whenever we don't have any life left, of course the game is over the levels over. We probably saved score to want to, we don't have to. And we also went over the, one of the bricks get destroyed. We can play some small, let's say particle effect if we want to. So we're gonna get some nice effects over they also have some background over here, which is just a Say a square or like a semi square which has rounded backside. And we're going to maybe animate some UVA's onto that, which is also a 3D model. We're going to take a look at how we can animate u, v's quite a bit just by using some coding as well as we, well, we don't go over the level design or the UI design because that is totally up to you. So I just give you probably this one I just created over here. So you can actually play around with that same for the 3D models. If you don't like this, of course, you can always create your own. So let's talk about some topics. So the first one is level design in itself as well as editor scripting, scriptable objects, as well as simple level design setup. So first off, editor scripting is something for intermediate people. So if you are actually new to game development, I recommend watching something else about probably, or maybe you start somewhere else or you just follow up and you will go to the final result no matter what, I just explained everything on the course. So what we are going to do with that, it's a scripting and so on and so forth. Also, I gonna go explain what a scriptable object is, which is, let's say not, not necessary, but it is easier later on to put that, for example, into a list and so on. So we are going to take a look into lists, floats, integers, strings. We're going to take a look into scriptable objects, editor scripting and so on and so forth. So a lot of topics we go and look into coroutines and so on as well. So whatever which we need in case of coding that we'll, we're going to make use of. So be prepared for that. That will be quite some coding. We're going to have to take care of the of. And also there will be some simpler things like GameManager system and so on and so forth. Like who holds the score where we do we save that and we need to save that and so on and so forth. Completely stuff we're going to take a look into. So also we're going to take a look into vector two's and all the other stuff as well as, as you can see over here, we're going to take use of or make use of lists, classes, and all the other good stuff like integers, floats, as I already explained before. So when it comes to level design itself, we want to create some level designers script which is going to handle the start position of our actual grid. We're going to talk about that whenever we start there, we want to have a possibility to tinned all the breaks. So if you take a look into this colors over here and also the transparency, you probably figured that these are going to be these ones. But, and since we want to automate that though, so the levels are every time, so we just create them inside of scriptable object has shown interface for that in a second as well. We want to make sure that this gets automatically created, automatically spaced, automatically placed into the scene. That's what the level designer is going to be. Four also, we have like a distance x and y, like the distance between two stones. And if we don't use stones, you can actually use anything. You can even use raindrops if you want to or any other stuff. Whatever you police in like and this is where we need to keep or yeah, keep track of the distance between. The actual stones also we are going to have an odd offset. I don't have an image for that, but literally it's just offsets the stones to like the half of that. So we have like a brick wall style, I would say a brick wall style possibilities and you can design that once again, how ever you like. Also, we can change how high the offset should be. And then we have this little level itself over here, which is going to once again sit in a scriptable object, which only looks like that. So when we are looking into this, we can see there are just some one else, some tours, some three years and two 4s in when I just go up. And again, these are the force, these are the threes, the green ones are the twos and the red ones are the ones. So basically what we do is we create a system which reads the colors, actually calculates and creates the stones like my jelly bricks over here. We're gonna go over and cover this as well. And then we automate it so that whenever we are, however, we have set it up this grids with its current grid size, so each level can be created differently. We want to make use of such grid. So we can't just say, okay, we want to have a brick of number one. So we're gonna take a look into this brick lists of here colored and position it wherever it has a one over there. So that is actually how we want later on to go into level designs. So everything is super simple to set up. And you can like, if you want to literally create hundreds and thousands of different levels by just this easy setup over here. Of course, if there is an offset, you just need to take care of that. Some of these may be have a 0. So as you can see, if there are zeros inside, no breaks are going to be created at these points, as you can see on the screen shot over there. Then when ever we are done with the level designer itself, we want to take a look into scores management. So how do we actually get score per destroyed brick? Also, we're going to take a look into physics in this particular case because we are going to make use of rigid body components. So whenever the ball collides to somewhere that it's actually able to bounce back into the opposite direction or opposite minus the incoming NCO, as well as whenever we hit the pedal More on the left side that we bring the ball more to the left side and vice versa, bringing the ball to the right side or more to the right side depending on how far it is away from the center point. Also, we need to have later on in some kind of a level management system in which we can load level 12345 by just using simple user interface buttons. And the final or almost finally one is we want to have an order me medically resizing frame, which is green resolution unrelated so we can block the ball from leaving the screen over the complete outside. We cannot see them over here because I just blend those out. We're going to take a look into this as well. And also we're going to take a look into the parallel, so we keep that in screen as well based on the outer resize triumph as well as we want to make sure that we can resize it like over time or like instant if you want to. And also we want to have a left-right movement so we can move that boost the arrow keys as an example, or was just horizontal inputs like the a and the D button on the keyboard. And if there is some time later on as well, we also gonna take a look into how we can. Drag it around with a, with a touch light, let's say was a leftmost click. So we can literally move the paddle left and right based on fall following the mouseclick there. But for the moment we just go for the keyboard input. Then of course we have a game manager which we need to script, which takes care of how many Nice we have as the game has been lost or won. And the bricks themselves are going to have just simple things like how much health do they have left? Because one brick can have like ten health and other one is just one. So it's harder to do a steroid, Maybe one or the other. So we're gonna take a look into that as well. And we probably dropped some power ups or power Downs like a D buffs or buffs, which we can trigger the pedal to be resizing over time, making a bigger or smaller if it is a debuff also, we are able to, let's assume, create a multiple thing or maybe there's something shooting from the petals. So it's something like three seconds. We have bullets coming out of the pedal or from somewhere next to the pedal, which are able to destroy these little boxes there as well on, whenever they hit the boxes or this little jelly bricks, the jelly breaks loose health at this point as well, there are probably hundreds and thousands of other different buffs and debug we can implement and so on and so forth. We can also put in something like as extra later on, being a with coins or whatever you are ideas are going to be in this particular case. So that is basically everything we're going to take a look into and probably some more things here and there left and right. So depending on whatever is necessarily going to take a quick look into user interface design. Well, not too much, but how do we resize these, let's say text elements according to whatever the screen resolution is. So we always keep track of that as well. So whenever some people do may only want to have like the portrait mode, so it's like upside down or the landscape mode, like left to right. Both basically you should work in the end over there. And once again, you are literally responsible for your own design in the total manner. So whenever you think my models are not good enough, but for learning purposes, these are going to fit pretty much 100% as necessary. And once again, feel free to implement your own 3D models as well as your own user interface design at this point, maybe late only also gonna take a look into a combo system, which means if in a couple of seconds or maybe in 1 second after a destroyed brick, another brick has been hit them, we probably put a number in the bottom over here in the center. And the top center where we can actually get some combos and we can buy based on this combos, we can implement the score over there as well. Of course, that is kinda luck based, but probably that is something interesting. You want to take a look into this later on. So that is everything we are going to take care on this core, take care of in this course. So if you're interested into it, feel free to join me on my little journey in how to create a 3D game in Unity engine. So, and I hope to see you in the course. Thanks a lot for watching and see you later. 3. #3 Unity Setup: Welcome back to the course. In this part, we want to set up our Unity Download if necessary, the corresponding version or any other version you present, like probably you have done and one already done. There's no issue with that. And you can use literally any version of Unity up from Unity 5.6 because we're using the new Canvas system, which is currently not Reza knew anymore. So when you don't have any installs of a year and I recommend using Unity hub where it's currently is available in 2.40 over here. And which we can, in which we can literally install any new version or any Unity version we want to use or want to make use of. As you can see, my newest downloaded version is 2K 19.3, 13 F1. You don't have to use that. But you can also, there are also versions of 2K2 already available. So if you are coming later or if you're seeing this course who are three years later after my course release, no voice, don't fear. You can still do everything over here. Probably there are some slight changes in the code, but that shouldn't be too hard at this particular point. Once you have that install and once you have downloaded unity hub, you don't have to use that. By the way, you can just go to projects and create a new project of here. So we go to New and you can literally choose from the list which version you want to make use of are going to change or choose to canine over here. Then you can create a new project of, uh, here we are going for the 3D face over there. If you need to, later on, you can always go and get the high definition random pipeline into this as well. But for the moment, we only want to make use of 3D and general. So plugins are not going to be downloaded as an extra, so they're not implemented. But we can always go and put any necessary plugins into the project. Give your project a name. You can literally name it whatever you like. I'm going to name mine brick breaker tutorial. You of course can name yours whatever you please, unlike, then you chooses download location over here. I'm going to do this pretty quick. And once you have selected yours and mine, it's just any random folder or where all my course projects are going to be inside. Then I press on the blue button on the bottom called create. Now, Unity will download or prepare any necessarily assets for you which are actually needed for the 3D workflow over the, if you are going to create a 2D game, of course choose 2D because you don't need like 3D lights and stuff like that inside. But the workflow in the basic manner is probably about the same. Maybe some of the other pieces are not the same, like maybe black re-sizing the border around later on as well. That can take a second or two. But once Unity has imported any necessary plugins and so on, it will open the interface. Once you energy has been loaded, you're gonna see different things and different screens. Yours might not match mine, but you can always do it the same way as my looks. There are three or four things you want to make use of or actually take care of. First, you always want to see the console window to. I do not recommend having the console next to the game view because if there is any bug, any problem, any coding error you in my year most of the time you miss the console error over there. So make sure that console is always like as a single parameter or as a single box anywhere on your screen. Same for hierarchy panel. So you can put this onto the right. I have my scene view and top. Some people are using scene and game, they're next to each other. I do not recommend it because if I do a change on the scene, I want to see the change in the game view as well, and that is necessary here. Another interesting part is the, let say resolution. Most of the time, Unity salts in free aspect we don't want to use, we want to avoid that 100%. So when you are going to work in the PC space, you probably want to start with 16 by nine or 16 by ten. Native resolution of 1090 by like 1920 times 1080 is going to be 16 by nine of here. So we probably want to start with that and laid on Shank if the other resolutions are working as well. You also want to see the inspector window. Usually I have mine on the right side so I can see all the components we are talking to and working with reza simple. Also, you might want to go and put your lighting tab, which you can open from window lighting, which is going to be inside rendering light settings. You want to open this window at first by clicking on it and then drag it over next to the inspector. We're going to take a look into this because we do not auto generate lighting. But when we setup our first thing's in the scene, you're going to see why I'm doing that or why this is necessary step. If you have all that completed, like everything is literally set it up. So nothing else but the pure interface, I would say, you can reduce the products over here because we need to have this later on also in which like all the 3D models will be inside or the scripts will be inside and so on. So we always want to see that at the same time as well. Once we're happy with the layout and you see, always see the console, you always see the scene view, the game view as well as hierarchy and inspector window. Then it could go over here to layout. And you can say save layout. And whatever you save a two, this is going to be oversized. So you just give it a name over here and then you press save and you can make use of the layout anytime. Let's assume you miss something or you have falls of wrong layered over here. You can always go, I have mine over here as well, which I can always go click on and it will automatically load the correct layout I want to make use of. Once again, if everything over here is going to be set it up, we are good to go to start the actual tutorial over here. 4. #4 Import & Paddle Setup: Welcome back to the course. In this point, we want to import the 3D models and start to set up the paddle itself. So first off, we go into our projects folder and create a new folder called 3D models. Actually, you can name it whatever you like, but having everything sorted is going to be super necessary. From the 3D files, zip file I just provided with the course. Please make sure that you answer that first and then bring in all the four FBX files into the 3D models files folder. In here we find a background. We're going to find a jelly brake pedal body and a paddle cap on the right side. And the inspector, whenever you saw an atom, you see at least that these guys do have no animations. If you are selecting the Model tab, you can also see what they're actually looking like. Same for the same for the body and the pedal cap. Now, what we wanna do is we want to set up our paddle first. So we're gonna create an empty game object at the very beginning. And we wanna make sure that this is at 000, but actually doesn't really matter where it is. But for the sake of let say, simplified progress, we want to make use of that at the moment. As you can see, my pedal is going to be renamed Whenever I just highlight this top area and name it pebble. An empty game object only has three things. It has a position, a rotation, and a scale. The position for us is going to be for us later on, Reza important. Also in the scene, we're going to have a camera. The camera renders only stuff which is inside this thrust room area. Later on we need to make use of this rostrum area and determine how big of a play field has to be based on a distance between the camera and the pedal itself. So the pedal object over here currently centered and the camera will not render anything because there is nothing to, to take a look at. What we can do. We can add 3D objects to the pedal. Let's do that. We just take our parallel body and drag it on top of the pedal game object. As you can see, it's kind of yellowish and I'm going to explain in a second why. Also you can see there's a slight offset. So we wanna make sure that this one here on transform X, Y, and Z is going to be 100% on all three axis to be 0. So the pivot point, if you are 3D modeller, you know what the pivot point is. It's the object's rotational point. So the pivot point is in the center of the body. The paddle. Has also a pivot. And now you want to make sure that both pivot points are going to be 100% of each other. The peddled bodies shares the world space coordinates of the parallel game object. So just make sure that this ones gets zeroed out of here. You can ignore them negative 90 rotation at this point. Also, you want to make sure that the scale stays at 111 and you don't change that. Create another one, which is going to be one pedal cab. Also drag it like on top of the pebble game object. What do you also can see is that the pedal cab is completely offset it. So first off, we go to 000. As you can see, the pivot point of the pedal campus like onto the left side of the paddle or of the cap itself. We wanna make sure that first-off we activate not Center over here, but pivot point. And we're going to keep that on global, but you can also go and local Netter if necessary, but we'll keep it on global. So now we drag it over the x-axis out of here. And now we hold down the V key on the keyboard and go over with the mouse on the sides. What's happening when we are doing that, I'm going to show the satyrs wireframe of a year and seen here you can see we snap to the vertices of the 3D model. So what you wanna do is we want to take one of the vertices and snap it to the vertices onto the site. This is not necessary but helpful for good understanding. Once done and you deactivate that, go back to shaded mode, you're gonna see literally no difference over here, only a render difference based on 19. We're gonna take a look again in that in a sec. And we want to duplicate the pedal cab icon, hit control D to duplicate on the Mac, it should be Command D if I'm not wrong. And then I rename it again. But now I want to make sure that I rename it even further because we want to know that this is the left pedal cab. I gotta hit E for rotation, or are you active or activate the rotate tool? Now you hold down the Control key and snap rotate. The whole method with the Control key 180 degrees over to the other side. And now we go and hold down the V key again and snap to the other side of the parallel. In the game view, you can see now that how it looks and what it is. The other pedal camp, I going to rename this also to be right pedal cap. We only do the CIA and the hierarchy panel. It's not necessary to do this in the acids panel because it doesn't make sense. Now we have the pedal setup. So whenever we now move the paddle game object, every 3D model and the game view as well as in seeing you, is going to follow that. We want to go back to 000 once again just in case. And now we're gonna take a look into lighting. So we go to the lighting tab view probably have entered over here, like set it up, as I explained before, is not go to Window rendering light settings to open this one will now go as further down until we find this auto-generate key or button, click that. And the lighting will automatically generated. As you can see now it's fully lit because there is no material on it and there's like a direct shine onto the side. On the backside you see shadows as well as at the bottom. This is good. Now, since we don't have any materials at the moment, set it up and there are no materials inside the 3D model. I gonna go and create a new materials folder. In this materials for the, we're going to create two materials, one for the center and one for the camps. So we go into, right-click into the Materials folder create, and then we look down for material. Click that and give it a name. I'm going to name mine grey. I go back and to inspect the view of a here and change the color to, let's say, bit darker gray. And I now take this gray material and bring this directly onto the model in the scene. Now I want to do the same for the caps. For my view, I'm going to unlike the orange color, so I create a new material named this one, orange. I go to the Albedo channel of the color of a hero of the material, make it orange. And now I grabbed the orange and put it onto the left cap and on the right cap. Now all of these to have materials, of course, not all is done yet, but we will get there. The panel body later on needs to have a knowledge about its size, but we're gonna do this by code. So what I want you to do now is adding two components. The first one is going to be a rigid body component. This is necessary for physics interactions. So whenever this body gets hit, it reacts to whatever it does. We wanna deactivate, use gravity because we don't want to use any gravity on this pedal. And we're basically done for the moment. Also, we want to add a box collider component. This box collider component usually starts with the size of 111 and should be automatically centered to the paddle game object. Once again, the panel game objects is just an empty game object. And we wanna make or take care of the size of the body or actually the rigid body as well as the box collider Ibid laid on. What does it mean? Well, we go later on for size of three in the x axis, because when we pass in a three over here, we have or in this case a two and my case of a two, we're going to have a bigger collider, but we are not actually necessarily needing take care of the camps themselves. So we resize it to however we think by code later on, we want to. So keep that as one because we are going to change that by code later on. So in the next part we're gonna take a look into how can we move the pedal left to right. And probably also how do we resize this component like this collider object or this box collider to its, let's say actual, real pedal size, including the left and the right pedal cab. 5. #5 Paddle Movement: Welcome back to the course. In this part we're going to start coding the pedal. So meaning we want to have a possibility to actually move the paddle left and right based on horizontal input. In that case, we want to go and select the pedal. And we want to add a new component to this. And we can name this by, well, first off, we select New Script and name this one paddle. Get Andrew to apply and we're going to get a new script component onto this. Once it has been created and the compiler is done running, we're gonna go into the assets folder and create a new folder called scripts. In scripts, we're going to put like all of our scripts over here. So take petals script and drag it into the scripts folder. Once again, on paddle itself, we should now have the RigidBody component, the box collider component, and the pedal script component. Once you double-click on this gray name or go and double-click the parallel script themselves. It should open automatically in your IDE. And in your case, it probably is Visual Studio. So double-click to open pedal script. And that doesn't work for you. You should take a look into your editor settings. If your script has not been loaded and your screen is still empty and you just go to your solution window and double-click parallel dot C S over here. So this is a new c subscript we are going to take a look into. Once again, if your IDE does not automatically open, go to your added preferences, and then take a look where the problem is going to be. In that case, you should go to external tools and take from the drop-down menu whatever your current iDS. I'm still using a MonoDevelop package, but you can once again, or you should choose your Visual Studio over the external script editor. We can take care of, is we can get rid of all these commands. So whenever you want to commend something out, you just type in two slashes and you can type anything you'd like at this point, or you're gonna do a slash asterisks. And then when you hit Enter and put another asterisks, or in this case another slash at the very end. You can also comment content out. Also, there are other possibilities like using summaries, but that is not necessary at the moment. Just keep that in mind. That can be helpful later on. What you also want to make sure that your IDE is loaded 1-2 percent correct. And you have a connection to the mono behavior, actually namespace over here or this class. So all others should be highlighted in green. That is not the case. Or as an example, you type in something and you do not get this list of possible inputs. Please make sure that autocomplete on your IDE works 100% Well, once you have that out of the way and your ideas has been loaded 100% and everything works as well as the autocomplete functionality. We can now start. First of, we want to make sure that our paddle is accessible from any point in the game by any script. To do that, we create some kind of a singleton behavior or singleton design pattern, or just single Singleton just gives us the possibility to have instant access. To define one, we just say public static paddle, and this is the same name as the class name, and we give it just a name instance. Now we create another function which is called a wake. It has to have a big letter a at the very beginning. Once you have that, we're going to just pass an instance is equal to this. So whenever we laid on, need to talk to the pedal, for example, when the game manager has to do something, when we have to reset the game, whenever we have to move the paralleled by, let's say code, then we can say, Okay, we can talk to this particular instance from anywhere. Also the game energy later on will have its own instance so we can instantly go and talk to Game Manager, for example, when we get score, when we're going to life's over, may reduce lives and so on. With that out of the way, we need to make sure that we create some more things. Like what is actually the game object of the left cap, the cap and the center. But also we want to implement something like move speed, starting size, and we are currently scaling as well as having a connection to the components sitting on the pedal itself. So let's start with the components on which are sitting on the parallel itself. So first component is the rigid body. We give it a name, RB. The second one is going to be a box collider. So let's name this one, c, o, l. So these are the two components which are directly sitting on our actual components like onto the pedal itself, like on the, on the pedal game object. If we do not put a public in front, they are not visible for us. That is also not necessarily because we can start whenever the game starts, whenever the level loads, we can already get those informations about them. So we can say RB is equal to and now we get the component, a component sitting on wherever the panel script is. So we get the component of type. We're going to put this into this triangle breadth embraces or parentheses. Put normal parentheses behind that and say semicolon. Semicolon always says, okay, the line density, line NCI, and we're good to go. So we're gonna do the same for the collider. As you can see, the colliders, a box collider. It just says, hey, give me some other name, but we don't care about that. We just say C U L is equal to get component. Open, close it's triangle brackets. And we want to get the box collider open, close parentheses, and close the line with a semicolon. We also laid on putting some other content into this. But let's take a look into how we can move our pattern. Now, instead of using update, we're gonna make use of fixed update because we're gonna make rigid body movement, which is physics-based movement, which means that we want to make only the use of that whenever we are using or moving bodies. So to move our paddle, we have super-simple possible inputs. The first one is we just declare a float. A float is just a common number of our current Horizontal Axis input. So I just name it H for horizontal, and this aids only looks for the input on the horizontal axis. So we say input dot get access law. So we get raw data from a horizontal input. And horizontal can be declared here in quotes. So you say how R3, x1 to this horizontal is setted up already in your inputs manager. We maybe go and look later to this, but for the moment we just don't need to. So just make sure that this is 100% written correctly, was a big age in the beginning. Once that is done, we wanna make some checks over here. So if h is literally equal to 0, we don't wanna move like because we don't have any input. So we say if h is equal to 0, it will do a yellow underline over here because this is a float and we try to compare it with a 0. To get rid of that little warning of here, we can just typecast H into an integer. So if integer h is equal to 0, we know that nothing happens at the moment, so we don't want to move our rigid body. So what we, but what we also wanna check first is if our rigid body is not already zeroed out. So we go and request rigid body dot velocity. Velocity is the speed in which the rigid body is moving like with a force as an example. So what we want to do is we want to check is that rigid body velocity is not equal to 0, so it's not zeroed out. And since the velocity is a vector three, we just request to check against Vector3 dot 0. So if there is no velocity or, or in this case if they are, are or is velocity and the input is 0, then we want to say that RB dot velocity, of course, is equal to vector three dot 0 because we want to 0 this one all we don't wanna do any rest of the movement. After we are done with SAS check, we just want to move the actual rigid body position. In that case, we use RB dot move position. Rb dot move possession takes, as you can see, a vector position as an input. This input is going to be the current position which is transform the position of this current game object, whereas this game object where the script is on. And then we add a new vector three. So we say mu vector three. So whenever something doesn't exist or whenever we have to add something we need to do. This was a new vector three over here. We put an open close parentheses. And then here we're going to input h as our x axis, 0 as our y-axis, and 0 as I was that axis. And then we normalize that. So we say dot normalized. And then we multiply that by our non-existing movement speed or speed. And we multiply that by time dot delta time. In that case, since we are using fixed update, we can also make use of fixed delta time, totally up to you. You can use one or the other. So fixed delta time in this case, is more like the rigid body part. If you don't like it or if something went strange, you can also use again, the normal delta time. This should work as well because that is like smoothing out the actual result. Since we don't have any speed value, we just put a speed of a here. And the speed is of type float. You can also make an integer as an int over there, but I recommend using a float. And then we can start to set this one to be, let's say ten. You can also put an F behind that because that represents even more that this is a float. This isn't only necessary if you have like common numbers in a float, then if you don't have an f, it will give you an error. So keep that in mind. I just start with TNF. And so speed of a here has no problems anymore. And we should now be able to do an input with using the fixed update to move the paddle. Don't forget to save the script. Hit control S for quick safe. And now we go back into Unity and see if our console has any issues. If the console says there are no issues though, nothingness in here and the compiler has done running. We're going to press play now and see if the paddle moves. If you like to, you can maximize on play, but you don't have to. I just disabled maximize on play, so it can just go with the input. So whenever I now move my paddle left and right, so I'm going to use the arrow keys at the moment, or I can also use a and D key on the keyboard. The pedal moves left and right. 6. #6 Playfield Setup: Welcome back to the course. In this part, we wanna take a look into the play field and the playfield size. First off, I want to make use of some boxes or in 3D objects. These are called cubes. So just create a 3D object cube. This cube will be anywhere in the scene. So we can also go to receptors in its transform. And we just drag it over to decide what we can do with that. We can also go and scale this one up by using the archi or just the scaling tool over here and scale it over the y axis. What's happening here is since dad already has a box collider, we can collide with that as long as it is not set to be a trigger and the pedal should not be able to move it away or even go and pass that. Exempt for the sides over here. But the box-like, the rigid body from the center point like from the PET bottle, body size is not able to pass that. Let's test it out. I'm going to go to the right and you can see I cannot pass that even if I tried to. It just gives a little, let's say feedback, but it returns back to where it came from. This is necessary so we can laid on keep track of the size and the actual position of our parallel. If I would go and select the pedal and increase the box collider size to be two later. Once again, we do this by code and try again. Currently I'm in play mode. So whenever I do changes in play mode, it will go back to not being, yeah, it will not be applied, but only here. You can see now the pedal is not able to pass. Boy, if I would go and copy this one to the other side, you can in play mode also copy and paste things around. You can currently see I just passed this pedal, so we take a look into this rotation, the very first. So we don't want the pedal to rotate. And to do that is first we go to constraints and we wanna make sure that we don't rotate the panel on X, Y, or even zed. Same thing is we also want to freeze the position on the constraints in y and z. So we don't wanna go upwards or downwards with dependent and we don't want to go over the xhat of forward axis into the playfield. We wanna make sure that we only be able to move into position x, left and right. With that said, we just can literally should be able to pass the pedal right now with the box, it will react to it. But we can only push it away as it can see and play them out. So nothing fancy for us. We can still go into the game view and bring back the pedal. The pedal cannot push away the border. So with that said and out of the way, we can just give it a name, like let's say right border. Then we duplicate this control D and bring this to the other side of the game field. Make sure you are not in play mode anymore and rename this one to be left border. We also need one for the top and the bottom. Now it's important that you, if you duplicate this, again, Control D, and bring the CIA that you reset the y scale to be one. And scale over X. This is necessary laid on whenever we are calculating or order medically calculating the border size wherever it has to be. So whenever we now put this, let's say anywhere here we only move it upwards. We do not go into the z-axis. All of these need to be on one line, no matter where they are at the moment. We wanna make sure that everything is, let's say a bout on the border of our playfield. Let's assume something like this. Probably more, probably less, if it is too deep for you or whatever, or the pedal is too high, that doesn't matter. Either you can just bring down the pedal. And final step is, of course we need one for the bottom over here, which is laid on going to be our debt down. So as you can see, this is now where we would have the frustum of the camera hitting the borders over here. And we would be able to, let's say fall down or let fall down a boy with a velocity of something. And then it would be able to, you know, collide with the borders because all of these to have balks colliders over here. If we would go and create a ball like right-click in the hierarchy panel again, 3D model or a 3D objects fear we would be able to if that has a RigidBody component on it. So we just added to the ball. The three-year can also be renamed to the ball if you want to. And let's assume we are using gravity over here. Usually we shouldn't, but we want to make sure that the ball is not able to move over the z-axis. So make sure that frees positions that is activated. It can rotate does matter. We just don't once the ball leaves the playfield over the death of the, of the playfield themselves or itself. If we would go and let the gravity on over here and let the ball fall down. It will be kind of okay ish. But as you can see, it reacts to the border and it reacts to the panel or the pedal over here. This is good and necessary. So we can now say Control S for quick safe the scene. And we now have a possibility to let the ball fall down, even if we don't use it this way. We have the possibility was the little pebble over here to not move along and we are able to kind of drag the ball around, but that's not what we want. We're gonna go and take care of the ball itself. Did later on. In the next part, I want to make it so that the frustum of the camera is calculating automatically the size of this little borders of the here. Why is that? So because let's assume we have a bigger playfield or let's say higher definition, like, more like a bigger play field where we have like hundreds of stones or bricks next to each other, then we need to go away from our actual play viewed with the camera. And if you play around with the camera, like you drag it away, you can see that the frustum of the camera has now like related onto our initial frame. It has an offset and we don't want to play the game to look like that. We want to make sure that it always looks like that. So the border is always at the rostrum size of the camera. And that's highly mathematical calculations involved, but I'm gonna show you how that works in the next video. 7. #7 Automatic Border Setup 1: Welcome back to the course. In this point, we want to take care of the boundaries like wherever the Later on in play mode, the frustum of the camera hits the border itself. We want to automatically calculate the borders rounded and scale them accordingly. So let's take a look into that. First off, we need to create a script which takes care of that. I'm going to name this boundaries. You can create scripts directly in the actual scripts folder by right-clicking, create new C-sharp script. For next one is I want to make sure that my boundaries object. We're gonna create an empty game object and reset it. This is going to be renamed to be boundaries. And you want to make sure that all the borders are going to be part of boundaries like as we did with the parallel. First off, I want to make use of renaming again. So this is my top border. And this other one is going to be my bottom border. Naming convention is king. Keep that in mind. You always need to know what is what because we need to drag the correct things later on into our boundary scripts. So please add those to your boundaries game object over here and double-click the gray one over here or there to open the script MonoDevelop or Visual Studio, whatever IDE you using. Once it has been loaded, we for the moment, get rid of starting update. Well, we need start, but let's put this together so everything is clean. First, we need to have a reference now to all our water, all our border pieces. So all the game objects we just made, like left border, right border, up and down or top and bottom. We're gonna make it a public game object. And now we add them by just using a name. So for example, we can name the first one left wall. Then we can pass in a comma, right wall if you like it the way, then maybe the top Wall comma and the bottom wall, the bottom walls later on going to be our dead zone. Also, we are going to take a look later on into corner pieces. So probably we need go and place some corners into the game as well because there's sometimes things going on which we are, I cannot assumed to happen or not. So the next thing which we need is we need to have the distance to or from to the camera. So we create a float and name this distance to camera. We need to store this information and we need to calculate this by or inside the start method. Make sure the start method has a big S and the beginning. Otherwise it's not working. And now we calculate the distance to camera. The distance to camera is literally since we are currently on the zeros, that axis is camera. So it's equal to camera dot domain dot transform, dot position, dot that. Or z, depending on where it come from. Also now we know, OK, this is like a negative something. Let's take a look. We have a Boundaries objects on the z axis is going to be 0. Keep that in mind. This is important also of course, can be anywhere else. Like whenever the boundaries unlike anywhere else then of course you still get the well-known. You don't get it because you need to calculate the different. So keep it at the position 0 over here, the boundaries, the main camera itself has to be have the tag, main camera of debt is not the case, so you have created a new one. Make sure you add the tag main camera, otherwise, Cameron domain does not fire. Over here. We have a position on xhat to be minus ten. Once again, if your boundaries are anywhere else, you probably want to say Boundaries position to that or the transponder position two of that minus the current position to that. Or maybe it's a plus depending on which direction you are working. So with that out of the way, we now know that the difference between the distance from the boundary xhat to the camera is going to be minus ten. We can now calculate based on this, we can calculate the frustum height as well as the frustrating with this code can be found by the way also inside the Unity API. So whenever you take a look into this, you can find it there as well. And whenever you have problems or struggled with some coding, you can always check or you should actually take a look into the Unity Scripting reference API. Api. We create a new void functions since we don't return anything and we're gonna name this one, calculate the boundaries. Open, close parentheses. There are no parameters given. The only thing we need at the moment is the distance to the camera. So let's create a new variable. If we are lazy, we can say it's just of type Var. So vara can be anything. Then we give it a name, thrust from height. So the frost Rome again is the size of the, let's say camera plane, like in its height from its current center to the current distance to the camera. So that's where we calculated two. So I'm going to name it thrust from height. If you are not sure about thrusts, rooms and cameras, you can always go and take a look into camera stuff. So now we're gonna do some heavy calculations. So first off, we multiply 2 f on just two times our distance to the camera. So we have a, let's say tattoo times negative ten. Then we multiply that by mass F dot. I believe it's ten, so tangent. And we pass in the camera's field of view. So camera dot main, Don't field of view. So it depends on how big that field of views. Then we multiply that by 0.5. In this case, we need to implement an F. And then we multiply that by mass F dot degree to radiant or deck to read. So this is how we calculate the frustum height. Once again, all of that can also be found directly in the Unity Scripting reference, the next one. And by the way, this gives us back a float. So if you go over here, you see that the variable type is going to be floats. Or if you don't like to play with variables or say just a var, you can also say, OK, this result is actually going to be a float. Same for the width of the actual frustum. We going to calculate this as well. So the frost room width is going to be equal to the thrust from Hyde. And now we're going to have it a bit simpler because we just take the aspect ratio of the camera. So we say camera domain, don't aspect. That's it for calculating this. Now, we want to calculate the screen boundaries and put them into a vector. So we're gonna create a new, I'm going to put it here, vector three over here and name this screen boundaries, boundaries. So a vector is nothing else like an x, y, and z coordinate anywhere. Onscreen. We wanna make sure that we know right into the screen boundaries Vector3. And we're gonna say it's equal to a new vector three. Once again, we have new numbers on new stuff. So we're going to put a new vector together and pass that over into screen boundaries. So in here an x we're gonna take the thrusts room with in y-axis. So the height of the playing field, we're going to put in the thrust from height. And the last one is that it's going to be 0 because we are staying at position 0 for our frustrated. By the way, we can also make this one visible by using some other calculation methods. Now that we know that we want to know what the current screen point is, the screen point is literally where the camera is currently at on its x and y, but not on the Zandt position. We still take that as a 0 position. So we know where the actual camera is on screen or actually on the point, literally like work, the center point of the camera. So we're gonna create a new vector three. We can also name the center camera, camera's center 0.2 and or in relation to that. But once again, we ignore the zed axis, the xat is the forward axis. We set this one to be 0 as well. I'm going to name this one screen point. So basically the screenshot where the camera is without the zed axis. So we sending screened point is equal to N mu vector three. And an open, close parenthesis. We're going to pass in camera dot domain dot transform the position dot x. Now we say comma, and then we're going to put the same in the y-axis. So I'll just copy that and paste it in here, but change it to y and say comma 0. Now we know where the camera is on screen or in the world. We also know the size of this camera. Frustrated. So now it doesn't matter where the camera is because it's all related to the camera position. That means now from this point on, we can reposition the left wall automatically or the right wall, or whichever world we want. To do that we need to calculate where that point is when we want to put our left war too. So we can create a new vector three over here, name it left point. And this is going to be equal to a new vector three of course. And we're going to put some parameters. Since that is going to be a bit bigger, I going to hit Enter and Tab two or three times so we can read it easier. The first one is the x axis, like the x point is Cameron dot main.out transform.py position dot X, which can also by the way be this green point dot x because it's still or it has the same info. So in that case, we can also say screen point, not just caring about screen point dot x, which is again, the cameras position x automatically. And we now we negated by the half of the thrust room width. So we say it's green point 2X minus frustrating width. And then we divide that by two. But the problem is that the frost from width could be a negative number. So we need to make it a positive number. In that case, to make a number, if, no matter if it is a positive or a negative number, we're gonna make use of mass F dot ABS. Abs means absolute. This means we always have a positive number no matter if the thrust from was has a negative number is as a result. Then we hit comma here and I go to the next line so we can, once again, we'd stuff easier. The next one is literally this green point dot y. Since, well, this is the camera's y position. We could also, by the way, use can remainder transponder position dot y over here completely again up to you. And then we have the x_1 axis, which is going to be just 0. Once again, if you don't like to actually type all those vectors, like top to bottom over here. You can also have them like in one line as y a we already had with the other ones. Again, totally up to you. Once again for easier readability. And if stuff goes longer, you probably want to do it like that. At the very end, of course, we need to create a semicolon to end the calculation for this point. Now what we do is we want to reposition the left wall. I'm gonna put a comment over here so we know this is all about the left wall. Now let's reposition the left wall. So the left wall dot transform dot position is equal to wherever this left pointer is automatically. Now we just need to make sure we scale it also at the correct size. So we say left wall dot transform dot local scale. And now we're going to pass in the screen boundaries because the scale we now need the height of the complete one. In that case, we're going to say is equal to a new vectors really once again. And now we're going to pass in all the necessary components on the x-axis. We want to keep it as it is on y and z. We can, for the moment put a 1-1-1 in here, but we want to make it so that it scales over the y-axis. So the height of this one now needs to be the screen bones y. So the frustum height, the full thrust from height. In that case, we're going to make sure that this is not a negative number. So we same as f dot absolute and an open, close parentheses. We're gonna put in the screen boundaries dot y, y because well, in here we have that and the y-axis represents the thrust from height. So we can simplify things by just taking care of all that. If we don't want to make use of them than we have to actually go and say frustrating height, that would work here as well. But, well, it's easier to just put in the screen boundaries. Don't, why? Don't forget to save the script. And in start, we want to make sure that we call calculate boundaries, open, close parentheses, and close the line with a semicolon. Now let's get into it and check out if that works. First off, we need to make sure that in our screen boundaries, we're going to have all our game objects dragon, so drag and right border into right wall, left border into left wall, top border into top wall and bottom into bottom. This one over here will now automatically set. It's positioned based on where the forest Romer's whenever we press start, let's check it out. As you can see now it's automatically resizing itself and positioning itself onto the left side of the screen. And we can know not leave the screen based on that. Pretty good. So now we also need to do this for the other ones, probably you already know how it works based on this left example. And in the next one we just copy and paste content around and update the rest of the borders. 8. #8 Automatic Border Setup 2: Welcome back to the course. In this part we let say finalize the boundaries of a here so we can 100% they make sure that whenever we are with our camera, we always have the correct size of the boundaries over here. To do that, we go and open our boundary script once again, since that is actually necessary to, for us to do this calculations. So as we already have talked about, we have the left wall over here. We just use the screen points. I guess I put all of that in one line over here because well, maybe it's not as long. And we already talked about the necessary content of a here. So I have like everything in one line, then I just make sure that I transform that to the position of the left point and changed the local scale based on the max MSF, absolute number of the screen boundaries y. Now we want to do the same for the right wall. So I'm going to copy left wall like the complete stuff with Control C. If you want to, going to rename this one here to be the right wall. And now you need to make 100% sure to follow up completely. So first off, we're gonna rename this one to be a right point. And everything wherever we are currently at with these things, like we want to change the rind ball at this point with the right point, at this point. So when we take is we copy this one and bring the CIA. So, and this one here needs to be the right ward. So rightward or transforms opposition as equal to right point rightward or transformed local scales based on screen boundaries dot y. But now we are not going to negate from the actual screen point with the frustrating with we need to add to it. So inside instead of minus, we say plus. Don't forget to save hit control S for quick safe, let the compiler run in unity. If that doesn't do what you're gonna see this always in the bottom right over there. You're going to check if there are any mistakes. Make sure once again at boundaries, all the game objects are set up correctly and take a look into or onto this one. If it is doing what it has to do. As you can see, it automatically resizes to the thrust from size. Again, this is based on the distance of the camera to the 0 on the world axis. Now, let's do this for top and bottom as well. So we open this one up again. I'll just copy this complete part for the right wall and make this one, let's say the top wall. The top was a bit different as you probably already understand. So I'm going to need to calculate the top 0.1. And the top point in this particular case is not the screen point y. And we are not taking the thrust from within this particular case. So we now need to, let say, turnaround the calculation. So in that case, we're going to get rid of this part. I just hear deleted completely. Because the x axis needs to be at the screen point X. So the center where the camera is, the screen point y is the one we need to, let's say lift up by the thrust from height divided by two. So we now need to test if it is necessary to increase or decrease the thrust from height. I would say we need to increase that. So we say swing point dot y plus minus aef dot absolute. So we want to take the absolute number of the frustrated no matter if it is a negative or positive. And now we pass in the frustum height. And we divide that by two because we only want to lift half of that because the cameras in the center of the point of the screen, point y in this case. Now we need to take care that the correct things are going to change over here. So we wanna make sure that this is the top wall, same here to the top wall. And we wanna take the top point to be used over here. So top Waldo transponder position as whether top point is now we have a problem with the scale as well. We don't want to scale over the max MSF absolute why we want to scale over the x axis. So over here. So y in that case is going to be one. X is now going to be massive taht absolute. And then here we're going to pass in the actual screen boundaries. And in that case, it should be the x axis of course. So screen boundaries dot x again, and here we do the same but with a screen boundaries so twice. So we take the height of the frustum size, and here we take the length like left to right of the screen boundaries dot x. Don't forget to hit Save. Let's go back to Unity and check this out as well. Wait until the compiler is done running. If there are no issues on the console, press play and see if everything works. Take a look into the top wall. As you can see, it automatically resizes and repositions itself to the screen boundaries. Thus, one is going to be the one for the bottom areas. So we basically just copy this content over here and just rename this one to be bottom. Bottom war. We're going to have a bottom point. So the point which is like sitting at the bottom of the screen, we're just going to be minus Missouri. Don't absolute thrust from height divided by two on the y-axis. Then we take bottom point, put this over here into the position and the top wall is going to be now the bottom wall. Same here. And now the scale is going to stay the same. It just scales over the x axis. Don't forget to save again. And let's take a look again at the compiler ran in unity. And we should now have four walls automatically resizing to wherever the thrust from cameras based on the distance from the center to the zero-point. So make sure that the camera is always onto the right side, like over the zed axis over here. Like always has a negative number. Let's assume we go away from here. And we want to have a play field in this size. Of course, the pedal needs to be repositioned. But when we press play, Let's take a look what the borders do. As you can see, the borders automatically resize themselves so we don't care about how big a play field is going to be, how small it is probably going to be, and so on and so forth. All of that is calculated now 100% and automatically on its own on sort of the game. And again, it depends now on, doesn't depend now on the screen itself. So we can now take or try to leave the screen using our little paddle over here. But we are just unable to do this because of the rigid body is not able to do it. Pretty good. I'm going to reset my camera now to minus ten later on we play around with that a bit and see what fits best. But because currently it should be a bit too huge for our screen. But well, if you are not going in landscape mode as I explained before, but the portrait mode, which you can also test by using, let's say a nine by 16 field and I hit play. You're going to see over here that the resizing will automatically happen as well. Of course, the distance to the camera is too small at this point, but it works. So I changed my stuff back again to nine by 609. And we are good to go with the boundaries for the moment. 9. #9 Automatic Border Setup 3: Welcome back to the course. In this part, we wanna make sure that we have something also sitting in the corners. In rare cases, the ball is able to just stuck somewhere in the borders like when the ankle later on is too small, then it can just go back and forth, back and forth on limited and we are not able to get that ball back from that. To avoid that, we create just some corner pieces which we can actually go and make use of and the boundaries here as well. But before we create them and we wanna make sure that we do this outside of boundaries so we can resize them to our needs. You can create a capsule or cylinder if you want to as well as you can also use a cube and just rotated by 45 degrees. That's what I do for the moment. So I just hit Control R to rotate. And now I'm going to scale that up. So scaling at least over two, but probably over three. That's totally up to you. So you go over here to scale for QB and increase the scale on x and y. Once again, if S3 is too huge for you, you can always go and test it out as well as make it the size you want. So what I want to achieve is that once again, when this is going to be the center point of our frustrate them. And we're going to have this cube like, let's say sitting in this corner that the ball is unable to get stuck in this corner. So let's take that and name this something like L corner or our corner. Maybe this is going to be for our, ours since it's already in our, our corner. Then we hit control D to duplicate and rename this one to be our L corner. Something like that. And then of course I bring this over to the other side just for being a visual representation. Again, if the size of three is too small or too huge, you can always go and scan over x and over why we don't need to touch the zed axis. Now we go and open up boundary script again and add the functionality or the replacement, the automatic replacement for these two pieces as well. To do that we can, or we have to. First, you assume probably have to add the game objects for them. So we say public game object. We can also by the way, bring them into this line of their completely up to you going to nameless L corner. And of course I want to have our corner at this point as well. I'm gonna make a big C so it's for me easier to read and for you probably as well. Don't forget to save. And now at the bottom of a year, whenever we calculate boundaries, we just position these things. So our corner is just going to be where our rightward point is and our top wall point is. So we say our corner dot transformed dot position is equal to. And now we just again put a new vector, three, open, close parentheses and put now left Wall comma. Actually not left wall but left point comma. And since that is the right corner, we need to go and to use the right point in this case. So write point in X, then the top point in Y. And probably IF a typo somewhere. But in here, we're going to need to make use of the R, the right point dot x, the top point dot y, and the z axis, those going to stay at 0. So we have now the x position from our right point, we have the top position of or the y point, y position of the top point. And we should be good to go gonna copy that and do this for the other one as well. So this is like the L corner. And of course, and here I need to change that positioning for the L corner game object. Now, we can make use of the left point dot x, since that is the other side, the left side and the top point stays the same. Don't forget to save and see what's going on. So whenever the compiler has done running, no issues in the console, I'm going to be represented. Don't forget to save the scene in between whenever you do changes can control as that for quick one as well. And you know, see there's unassigned reference exception. This unassigned reference exceptions always happened if you forgot to put any of the game objects wherever they have to be. First I make them part of boundary. Then I drank the L corner in the L corner and the corn and the arc Honor game objects don't forget to save again because this needs to be saved. And let's take a look. So as you can see now the, this corner is going to be 100% at the position where the colostrum is as well as the other one. Once again, if you need them smaller later on, you can always go and resize them. If you are not sure of the 100% of the work, bringing away the camera and press play again. And you're going to see if they do reposition automatically in this corners, which they do pretty decent and absolutely necessary. As you can expect. 10. #10 Ball Setup: Welcome back to the course. In this part, we're gonna take a closer look into the ball and its current or necessary behaviour. First of the ball already has its sphere collider on it, which is necessary as well as a rigid body. The first thing we want to make use of is no gravity. So we don't want to use gravity at all. Again, we've already constrained so that it is not able to leave on the over the zed axis. So we cannot fall down this or that way. So the pedals not able to reach it. Super, super important. Next one is we wanna create a C-sharp script and call this one just ball. You can also name this whatever you please in like the next thing is on ball itself, we want to create a tag. A tag is just so whenever collision happens that we can check against who we collided with. N contains a tank called ball. So we add a new tag, hit on the small plus and say ball. Now we select a ball again, go again to tanks and select Ball from the list. Now we drank ball script onto the ball and open this one up and MonoDevelop of Visual Studio. Once it has been loaded, we get rid of the commands if we don't need them, well, you probably don't. And now we also get rid of the update loop because the ball doesn't need any update. So first things first, we want to make sure that the ball ranks completely correct. We want to grab the RigidBody component of the ball so we can actually do something to it. We just give it a name, RB. It doesn't need to be public since on start, we said RB equal to get component of an clustering of brackets, rigid body, open, close parenthesis and the enters as a semicolon. Now, let's assume we don't have, we haven't done anything yet and that's what we didn't. We want to make use of some force. So this is for debugging purposes only we're going to do laid on some, some changes on that. So I just make a little command over here. This is only for debugging, so keep that in mind later on we commence the fault or deleted. So we now talk to the rigid body component and we want to add a force. This force needs to be of type vector three. So of course we need to pass in a new vector three of the here and now we can pass in three axes. At the end, of course we put a semicolon as usual. So usually we would do something like on the x-axis, the y-axis, and the z-axis. There'll also, as you can see, other possibilities but just doing an empty vector, just an x, y if it is a 2D one, or x, y, z, or x, y, z for the three directions actually. We don't want to touch, why? We don't want to touch Z, X atom on, we'll only want to give it something on the Y axis so we can take a look into this. So what I will go for is I want to create a public static afloat, which we can later on access from outside if we need to. And we're gonna pass, go give it a name. Like initial force. Can also name this initial speed. And I want to set this one to be equal to, let say, we can start with 500 or 600. That's something around there. Well, we want to go to and in that case, I'm going to take this initial forests and passes into this parameter of the Y axis. Over here. If you want to have like a, let's say diagonal one, then you can also put the force over the x axis as well. But we once again do this later on. So when we now hit Save and go back to Unity and let the compiler run. Once again, make sure you use gravity is disabled. In here, we're going to hit save because we did something to the scene because we changed something directly on the ball. The ball gets a force over, as you can see, over the y-axis and is now sticking onto this side over there. Because, well, the force was probably high enough or too high or whatever, or maybe the distance wasn't good enough at this point. So if we drag this one down a bit of the here, you probably will see that this one just flies up and stays where it is. Probably doesn't even rotate or do anything, just that. You can also test this one out if the ball is somewhere on the side that the corners are going to be taken in place here as well. So it's rolling. Now with that initial force over this one, like over the wall. What we want to make sure that the ball's able to bounce away whenever it hits something. For doing so we're going to have to create a physical material. I'm going to put this into materials because well, it's not directly a material, blood. Well, you get the idea in a second. So it created a new physical material from the Create menu. We named this one pounds. And if you have any typos, you can hit F2 and you can read, rename things inside the assets folder or into the project window. What we want is no friction at all. Maximum bounciness of one. A friction combined as being the minimum, abounds, combine of being a maximum is maximum is two huge. You can also use average bounds combined. Let's assume we have a maximum over here. And I'm going to bring this like a bit more downward so it has more size and more stuff to do. So whenever this now bounces away from somewhere, which should anyhow bounce away from somewhere when it hits something. But currently it doesn't hit anything and it doesn't bounce because we don't have the bounce material on our board. So we now click on the ball and you can see in the sphere collider we have a physical material part in which we can drag the bounce material into. Let's try again and see what's happening. Now you can see the ball is able to bounce away no matter what it hits. And however it is something that can also push away things and probably it stops at a specific point, like in our case, whenever it hits like the actual pebble over here. And when we go into corner piece or two jumps bounds away from this point as well. If it is like, let's say close enough to the corner. Again activated and probably does like it's sideway bounds anyhow. And currently it doesn't. But what it shows us that this can always happen, that the boy is probably doing some fancy movement like that. With these corners, we are 100% fully able to catch on one side or on the other side, catch the ball boy falling down into the dead zone. Currently the deadzone doesn't do anything but bouncing back our bone, which is good. So in the next part we're gonna take a look into how we can react with the Pebble onto the ball. Over there. 11. #11 Ball on Paddle Reaction: Welcome back to the course. In this part we want to take a closer look into the panels. So whenever the ball hits the panel and wherever it is like the pedal, I mean, then we want to make it so that whenever it's to the left side and it pops motor left if it's more and more right-sided, pops back to the right side. In that case, we want to make sure or make use of different forces at this point as well. So we get a bit more, let's say, different movement at this case. To do so, we need to open our pedal script once again. So I switched over. I am going to close these because we don't need them at the moment. And we'll just create a new function. This function is called type void. It's called on collision enter. So collisions are different than triggers. Collisions are more like when two rigid bodies are going to hit each other, then there is some reaction. Colliders or triggers in that case, do not take care of rigid bodies. Well, there's only one rigid body necessary, but also we don't have any, let's say re, organization happening at this point. Meaning we don't need to take a look into the different rigid body whenever the actual collision happens or the triggering happens. So there's only one rigid body necessarily on triggers, on colliders. We probably, and most of the time need to rigid body. A rigid body hits another rigid body, otherwise we don't get a collision. Makes sure on collision enter has these uppercase letters and also it always takes a collision, I guess into consideration. So we say collision and give a just a name. Let's say, since we have a collider named CEO l over here, we just name ID collision. So we can also possibly, you can name it other, Other collider or other collision, whatever. It's just a collision, it's nothing else. So whenever that happens, we can measure Who are we actually colliding with and compare tags and all the other good stuff. So that's what we start with. We first want to check who are we colliding wisdom is that if it is a born, so when we can say is if collision dot and now we can compare tanks, but we cannot compare tags as a trigger condition, we need to grab that game object first and then we are able to compare a tank. The tank we are looking for is the tank ball we created for the ball itself. So if we are hitting or the ball is hitting the pebble, we want to react to it. First off, we want to grab the RigidBody component from the bowl. So we say rigid body ball RB is equal to c o l. So collision dot, game object dot. And now we want to get the component. Omegas triangle brackets and passed by the RigidBody component, we are requesting open, close parentheses and close the line with a semicolon. Now, we want to calculate a velocity. I just shorten this one by VL. We want to set the velocity by porn dot initial velocity because we want to assume that we're going to put this velocity over the y axis as an example and just say semicolon. So there's just one static behavior onto this ball, initial, initial force. That's what we're going to make use of. Now, we want to see where the hit point is, where who actually were the ball hits us. So we're going to take a vector and this vector hit point. And the hit point is equal to where our Collider or the collision objects hit it on the other collision object like the pedal object or the paddle rigid body. This is stored in contacts and we only want to know the first contexts over pass in a parameter of 0. And then we take the point which is representing a vector. Once we have that, we can now determine the distance between the hit point and the current position of our pedal. So this is the difference between the two. We say we create a new float, call it difference. And we say equal to transform dot position dot x minus d hit point x. Now we know the difference like we know if it is a positive or negative side literally. And now we can measure if we were more left or right of the transformed position axle of the middle side of our paddle. In that case, we can request if hit point a dot X was literally smaller than our transform.py 0.8x. So the pedal center x, we know the ball hits more left. Otherwise, of course it's more right or basically Center. Now we can add a force to the balls rigid body. So whoever was hitting us, we can give it back and forth. So we can say ball RB dot add force. And now we can give it any forcefully like two. And then case we create a new vectors ray because Ed force requires the vector three, we're going to take a negative value off. And now I put another pair of parenthesis around it of mass F dot absolute number. And the absolute number is something like the difference multiplied by 200. As an example, this is for the x-axis. And we're gonna make a comma here between those. Maybe we can get rid of these parenthesis of the here, but I would like to keep them there for the moment. Then we want to pass on the velocity over the y-axis. And then we put a 0 on the xhat existence. We don't want to give a force over the zed axis. I'm going to copy this line. I'll bring this over here once again, as you can see, it's grayed out parentheses. So it says you can get rid of that because we can take the negative absolute over there if we want to just with one pair of parentheses about the different times to a 100. But, well, that's okay. But in the second case, since we are going in the positive direction, we get rid of the negative sign. So we now in this particular case, can get rid of the pair of parentheses around it. So now we're going to be able to make a positive move, like a positive difference or a negative difference over x axis. But the velocity, the initial force basically we grab a from here, is going to stay the same. Don't forget to save the paddle script. Hit control S for a quick safe. And let's see if that works in any way. I am going to make it so that the ball now gets a position over the paddle so we see any kind of an impact. So we going to, I'm going to drag it all over. Of course it will have a force upwards first. I'm going to make so that at least hits something on to the rigid body of the pattern. And that should go into any of these directions based on the difference between the center point over the Anakin C was like slightly going to the left and that keeps going on and on and on and does like whatever it does based on the other ones. And I can see it also reacts to the other side, like to the right side, depending on the difference. Once again, we can see this better if we would go and increase the parallel, let say rigid body. On this case the box collider Make it a four. As an example, you can see in play mode everything is possible. So whenever it hits Mike Moore and to the right side it goes more to the right. If it fits more on the left side, it should go more the other side and the pedal is literally able to do something. So whenever we now move on a pedal around, we can try to catch the ball. You can see it adds up in forest, but also tries to grab down on go down whenever it hits, depending on where you have the possibility to manipulate the ball. However we want to based on where it is actually hitting the pattern at all. Don't forget to save your seeing whenever you have done any major changes, like waves control again. And the pedal now works at the ball, reacts completely correct to it. 12. #12 Resizing the Paddle: Welcome back to the course. In this point, we want to talk about how we can resize the panel. Meaning currently we only have a cube literally in the center where we have no overlap over here for, with the actual box collider sitting on it. So we wanna make sure that we resize the box collider as well as the actual inner peace. So we can scale those outwards depending on probably some float or any kind of a number we can set in. And we also wanna make sure that these parts of here, like the caps own going to move with the outside of that soil is based on the pivot point in the center. So the calculation, as you can probably think of, is we're gonna take the current size which starts at one. And if we multiply that or set the size to be being a two, then of course we have like the double size on that. Also we need to add 0.5. or somewhere around that and 0.5. to increase the size of the box collider in the center. This is necessary, otherwise, these points over here are not going to be calculated in. If that numbers here are not going to match, then of course you can do a 0.6 and on each of these sides. So in total, we would add up at 1 in the end to this center point size, to the size of that middle pedal. So, and also that since that box in the center is going to be one at the moment, the half of that size is 0.05. here as well. So if we now would add a one to it, we wouldn't need to go and stretch that of course, and multiply that by that number, so one times two. So this box would have a total length of two, like in case of scaling. And the outer box collider should be like a two plus the 0.5 on the left and the 0.5, right? And of course we need to rearrange or we position these pebble pieces, like the pedal cabs onto both of these sides to the pivot point based on here, plus half of the current size of the box. I hope that makes sense to you. So currently there are sitting with the pivot points which are going to be like of the yarn to the site where these camps are going to be docked at. And the same for the other one. We know that this different current difference currently is 0.5. so the half of the size of that square of the inner peace. And if we have a two over there, we would need to add one to it. So this piece needs to be per reposition to one instead of 0.5, same for the other one just in the opposite direction. So now that you know what we are going to do, let's head over to unity and go and open your pedal script so we can write into it. We need to create a function which is taking care of that you can name this resize pedal or anything similar, however you please like once again, and as always, what I want to pass over. Is a float as an argument which is going to represent the scale. So like the goal size, I'm going to name this x scale because literally it is taking care of scaling the centerpiece and reposition based on half of the scale coming in. So what we wanna do is first we want to initialize or actually grab the current scale from our actual centerpiece. The centerpiece is currently not in our paddle, so we need to add the three game objects now, like the centerpiece, the left cap and the right cap into here as being gained objects. So we can take public game object, center, comma, left cap, common, right cab. Once we are done with that, we have the possibility to drag these pieces into the inspector. Once we are having these ones available, we want to calculate what is the current initial scale of the center. So we can say vector three initial scale or inert scale is equal to. And now we grab the information from our centerpiece. So center dot transform dot local scale. Currently our scale is 111 and all these directions. So we can simply modify and recalculate the scale. Or we now want to do is we wanna change the initial scale. So we type of right into this in its scale. But we want to do this by or only on the x axis. And what we wanna do is of course we want to flush in the incoming x scale parameter. So if we are sending an a two, we want to set the initial scale over in this vector over here in to this new size. Once we are done with that, we need to apply that to the center piece. So we say center dot transformed dot local scale is equal to the initial scale. Why do we need to do this? Because we cannot write directly in the x axis of a local scale. That's why we initialize a new vector first, change the vector, apply the vector. Otherwise we have no access to the x coordinate or any other of these coordinates. If you need to do anything on the y or z axis and the future of other programs or projects, then this is the way to go. And of course, the news talk to each of the axis separately by whatever vector or ever float you wanna pass by or passed in, and then you pass or peasant over back to the actual local scale of the centerpiece. Let's test this out. Going to go in my start function. And I want to call resize and want to pass an a2 f over here. We're going to see some weird stuff going on in a second. But that's okay because that is the first step of rearranging that piece. What we could do is we could, if you want to do this in an editor time, but later on we want to change that by code as well, like overtime resizing the pedal. Women now start, as you can see, the unassigned reference exception again, because we did not put the game on objects. Directly into the actual possible, or in this actual spots over there. So we open the pedal. The pedal body goes to center, the parallel or right panel camp goes into the right camp. The left panel cap goes into the left camp. Don't forget to save your scene and hit play over the NC what the Center is doing. Well again, see now the scale of the center got increased by the scale Mt I passed in. Currently scale is x2. So dance, how we actually change Dad? Well, we didn't change is dx of Box Collider because it's not part of the body, which is good. The next step is, we now need to reposition these camps to the same size based on the pivot point as explained before. Let's go back into our script. I'm gonna keep resize to F over a year in the start function. And now we can go and take a look into the left tab. I'm going to comment that out. So I laid on remember and you probably want to do so as well. We first off go and catch the current left cap position. Or in that case, we just create a new vector, how we want that to be in the end or to reposition that basically. So our left cap position, so I name it left ket P is equal to a new vector three. And now we can pass in any parameters we want. We want to keep the left cap, scale that or the left cap position on the y and on the z-axis. So first off, I'm gonna put in three zeros over here. Don't forget to put this into a pair of parentheses. And now what we wanna do is in x, we want to do the change on scale. We wanna do not touch the position on the zed, o on the, on the y-axis, on the current position. To do that, we're going to take the left cap game objects current position. So NatCap dot transform dot position dot y in the center. Let's discuss the center or the center of the vectors. So the Y axis on the vector. I'm going to copy this part because we're going to do the same for the z-axis. So in the end are going to put a xhat. So I don't want to transform them over the Y or over the z-axis. I only want to have that repositioning on the x axis, which is the axis left and right. So now we want to know, okay, since dentistry left cap position when you need to take the current left cap position. So NatCap dot transform dot position dot x. And we wanna negated because we go to the left, we need to say minus minus one. What we have is the scale parameter, which we pass in over here as an argument. And if we say we divide that by two, since the x scale, we only need the half of that, as I already explained in Inkscape over here. So we only need to take the half of the current size. So in that case 0.05. and if we have a two, then we want to only have one. A total repositioning to the left. So in that case, we divide the incoming amount by two to reposition this one correctly. If you are 3D artist and you create your own camps and your own pedals, makes sure that the pivot point is far on the right or far on the left. So where the axle cap position, as in my case, it is going to be once again, the point over here in where these two would hit each other. Once we have that, we're going to press play and see what's happening over here. But actually there shouldn't be anything because we do not apply the actual repositioning. So once again, we take the current trends on position and navigated by x scale divided by two. And we're gonna, we do not change anything on the y or even on the Z position. Now to apply that, we just say As we already did here, but we are not using the local scale, but the transformed position. So left cap, in this case, once again, the game object left cap dot transform dot position is equal to the left cab position we have precalculated. Don't forget to save and let's go back and see if the left gap is going to move to the left. When we resize that to the correct position. Of course we took the wrong parallel part. We don't want that parallel part being from the current left cap possession. We will not take the current x position from the center. So sorry about balance. So we need to go from the centerpiece, the exposition and negate that, of course, and not the current pedal position because that is sitting half a unit or 0.5. in distance from the center. Let's test out again. There we go. So now we have the correct position of the left camp, sitting next to the centerpiece, away from it over a distance of one unit in the end. Pretty good. Now we're going to go and apply the rest to the right cap as well. So in that case, I just copy this piece or part of code, going to rename my little command over here to be the right camp. I'm going to create a new vector called write cap. Pay us. We're going to take from the center, but we have to add to it. And now we are going to take the right cap dot transcendental position. We can copy that part if we want to as well. So we can double-click control C, control V. And we are able to put that in this position here. So also we take the right care transponder position dot y and x_hat. And the end, we once again go back from the Central or we calculate from the center to the right side by adding the half of the scale coming in. And now we go and reposition right cap based on our right cap position of here. Don't forget to save. Let the compiler run and press play and see if everything works. Pretty good. We still have the problem that the rigid body, or in that case, not the rigid body, but the box collider does not have the correct size. So let's take care of that as well. First off, we need to get a connection to the box collider if we don't have that already. So, but we already have the box collider of here. We need to take a look into start. If we getting the component over here, if we don't, then we need to do this. So that works as well. So now we want to make sure that we re, calculate the actual collider scale. But beforehand, we're going to set it to something. I'm going to make another command, Collider scale. We're gonna create a new vector three again, because the scale of a vector or of a collider is also being calculated in a 3D manner. We're gonna name it cURL scale, and we pass over our initial scale first. So our initial scale is only the scale of the current that say middle piece, the centerpiece. So we need to add half of the size to the left and half to the size of the right here as well. But before we do that, let's test out what's happening over here. So what we said is the collider dot size to be equal to our call dots gay or call scale in this case. In between, we need to add the paddle pieces like the panel caps. But beforehand, let's take a look and see if the collider gets correctly scaled over the size. As you can now see, the size of the box collider has a two as well, which is the initial scale coming in from our initial setting of the panel, Like onto the start function. Now we want to add this part and this part. Since I don't know the correct sizes, we need to play around with Dan one, i will start at 0.5. so if we add 0.05. here, 0.05. here, we need to add a total of one. You can do it like mathematically super heavy if you want to. So in that case, as an example, we can say call scale. Once again, we only go into the x axis of this particular vector and change that. So we want to add to it. So we say plus equal something. What do we want to add is the number one. We start with the number of one. We're going to predict that this is going to be as 0.5. you can also do something like 0.5. F times two. Basically it's the same because every side has half of the size of a here. We're going to save that and take a look again. And if we have any major issues with the size of the collider when we press play, we can also increase the 0.5. at this point. Now you can see the size is three because it's adding half of the sides like 0.05. here, 0.05. here. And beforehand it has a length of two. I believe I have to add a bit more, like maybe 0.06 five or maybe 0.7. let's take a look. I'm going to start with maybe 0.6 times two. You can also pass over 1.2. At this point. Basically, bows are going to do the same. Checking this one out looks pretty good and rather close to the original size of the paddle. If there are any slight offsets, of course, take a look into them. And also you can see now that the x size now is 3.2. If you are happy with the result, well, I am, I'm gonna take it as it is, save everything savior c. And if you have done any major changes, and we're good to go over here. 13. #13 Exposing Resize Parameter: Welcome back to the course in this part, I just want to expose the actual flowed of the size of or the initial size literally, before we go into resizing. What I mean by that is I want to take this to f now and create a float for it. A float again as a floating point number, we can say flowed re-size or let's say New size is equal to two. Now instead of calling resize to F, we can say resize to new sighs. Don't forget to save. And the good thing is before we expose it, of course, we need to make sure that this one is a public variable. A public variable can also be changed inside the inspector, as you already see with the game objects. So once it's public and the compiler is done running, we should see the actual new size parameter as well as the input number of two. If you don't like the position where it currently, as you can also put it like above the complete ports over there. Totally up to you. In my case, I could go here. And if you wanna go further with editors scripting and parts like to make it even look better then of course you are able to do so. We don't touch this in this particular case because it's not really necessary, I would say. But what we can do is we can put probably something like a space in between. So we type in two square brackets and then type in space. This space just means that between this value and the first game object's center value creates a little gap in between those contents of here. And as you can see, all of them now have the space in between, which is actually not what I wanted. Why that happens is because all of these game objects are in one line of code. So it exists or give all the same possibilities where we need to do, to do avoid that as actually create two more public game objects. Take those left camp and those right camp. I just double-click and paste content and just control S to quick safe afterwards. I just do it like that, organized that the birds get rid of the ones which we don't need. So we actually have all of them under each other. And now the space only applies between New Size and center and the other ones will keep the same size in-between. Once the compiler has done running, you're going to see the effect. Now. We have like a little gap in between, and that's everything we need over here. And the final thing is to test out, let's assume our new size has to be of scale for an a center, we're going to take a look and check out our paddle. As you can see, the box collider does correctly resize. The box in the center has now a scale for and these ones are repositioned completely correct over here. And the last thing you want to probably testers, can I still leave the the actual screen? Well, no, I can't because the rigid body is reacting to the actual box colliders. 14. #14 Brick Setup: Welcome back to the course. In this point, we want to take a look into brinks because we need to have something now to destroy and to get score and all the other good stuff. First off, in our assets for now I want to create a new folder called prefabs. A prefab is literally something, what is a template for something to make use of data? And we want to have multiple, let's say prefabs or templates for different types of breaks. To create a break, first-off, we navigate to our 3D models folder and we're going to take jelly brick, or you can also use your own ones and bring one into the center of the screen or anywhere in the screen. I'm going to put my brakes Mike zeros 0.05. and why? Well, basically doesn't need to be in 0.5 y, but well, To see it better, we're gonna put it anywhere. We can also put it wherever it could be laid on, but it doesn't really matter where it is. First of, I want to create a material so we get like a jelly. Like, yeah, let's say look on these four that I'm gonna create a new material. So I go to my materials folder, create new material. There is one is going to be my jelly or whatever you call it. Materials, instead of only have an opec, rendering modes, do also contain transparent rendering modes. There are also some others, but we don't care about those now. Also there are different shades to make use of, but we don't care of these as well. What I wanna do is I want to reduce the alpha, like the visibility and transparency of the break so much that we can see also what's inside the actual bricks. So we click on albedo, go down to the a channel, which stands for alpha, and reduce it, actually 0. And now we take the jelly material and drag it onto jelly break. Now we can see everything which is inside the, if the alpha value is too high, which can happen, of course, we can also play around with the actual alpha value. Probably something about 65 might fit if not, genders change it. I can also check it. Boy, going in and taking a look into phi would apply a color and see how high I need this alpha to be to actually see through, like get all info, but still have a nice visual. Probably we go even further with 120 or something like that. Once we're happy with the result, are gonna make it white. Again. Once again, this can be too much, This can be too low, we don't know in the end, we're going to see that later on when it comes to gaming at all. To see it even better probably will check out our game view meanwhile, so we can go to the main camera. And instead of Clear Flags Skybox, we choose Solid Color. And I'm gonna make it black so we can see stuff easier. If that thing is to sign in or somehow the material doesn't fit our needs. We can also play around with metallic and smoothness values or so. We do have specular highlights to disable and enable. So I'm gonna keep mine earn enabled. And we also can provide reflections, which are actually reflecting whatever is outside. What we can do is we can go up wisdom, metallic value, but I don't think that is what we need. Instead, we wanna change the smoothness of that algebraic so maybe was a bit higher. So we get a more glossy and more glassy style look of a here. I believe I keep mine as they are. So once again, my smoothness is now at 0.8 or somewhere around that. Once again, play around with these values until it fits your needs. The next part is we need to make sure that our jelly bricks also do contain rigid body components. And we need to make sure that this rigid body components are not using gravity, otherwise they will fall down, which is bad, as well as we want to freeze them in rotation and in position because you don't want to move them. But we want to have a possibility to react to them. So whenever the ball hits one of these rigid bodies, we want to do something. Later on. We may or may not get rid of the rigid body for, but for the moment we just keep it as it is. The next part we need is a box collider. So they represent the size of our actual jelly break. If you want to be more precise, which by the way also is more coastal intense like in calculation wise, you can also make use of a mesh collider, but I don't recommend this. So the box collider is more than enough, more than we need. And if now our ball gets heads or will hit that little brick, as you can see, it will stick onto it. We want to also create a little script for our break. So we go to our scripts folder, create a new C-sharp script, and call this one break. And of course we're going to drag that breaks grabs onto our jelly break. Once we're done with that, we want to create a prefab. We can just take the jelly brick from the scene, from the hierarchy panel and drag it into our prefabs folder. Of course it works also another folders, but, and here is where our templates have to be. And just leave it go. And you're going to see we have original prefab, peripheral variant or nothing. We're gonna go with original prefab. You can also take a look into this little preview. If you don't see that you can left-click onto this double edge line over here and then this little preview will open up. And the next part we're going to go into coding and see what we need to put in the break to destroy it and to react as a church like so it bounce back the actual over here. 15. #15 Brick Script 1: Welcome back to the course. In this point, we want to take care of the bricks gripped. So please open this one up and MonoDevelop or Visual Studio, and we go and get rid of the update loop as well as to commence if we don't need them. The next step is we want to see how we can give a brick health so we can create a new public integer. Integers are full numbers, not like floating numbers. So we cannot have any common numbers over here. And we're gonna name it health and give it a standard value of one. So we give our brick some health. So whenever a ball hits it, we want to make use of health and reduce it until it hits 0. Once it hits 0, we want to destroy the break. So we can have super heartbreaks, which probably have health of four. So we need to hit it four times before we are able to get rid of the brain. In start, we wanna laid on and I do some commands over here because we have to come back, report or actually add the brake to a game manager. We don't have the game manager yet, so we're gonna make a commander. I do a command over here. I want to add this so I know when the game is over because the game manager laid on texture or keeps track of how many bricks are still in the scene. Also, we laid on need to remove it from the Game Manager whenever we destroy a break. We also want to put something like a public score. So whenever, And of course it's of type integer for me here as well. And we're gonna say a standard value of maybe 50 or whatever you please, Nike, you can also take any other number higher or lower, totally up to you. Now we need to create another function which is literally taking care of. If we take damage, then we want to reduce health and report to the score as well as to the Game Manager later on. So in that case, it needs to be a public variable so that we have direct access to it from whoever is colliding us, and this case, of course, from the ball. So we're going to name this, take damage. You can also name this whatever you please. Unlike we can also implement a number how much damage we want to actually do over here. So we can manipulate numbers later on and reduce health not only by one, but maybe by whatever the incoming amount is. I don't do this. So for the moment, we're going to say just health minus-minus. That means the same as minus equal one. So we reduce the current else no matter how high it is by one. Once again, we can type minus-minus because we only reduced by one. If you use an argument, of course you say health minus whatever the argument is. Next step is, we want to check if our block still has enough health, so is literally higher than 0. So we can say if the health is smaller or equal 0, we know the breakfast destroyed. So we can do some facts, we can do some sounds, we can do something else. So all of that now is going to happen, but it has to happen before we destroy the game object. So as an example, I'm gonna do some commands here. Again, we're going to can create a particle's, create particles as an effect. We're going to have to report to the game manager. And of course, we need to make sure that we report later on to the score manager. If we actually have one report, report to the score manager. If we have one, and then we want to destroy the brink, destroy Drake. The Destroy has to happen after everything else. That is the last step over here. And if you need time, in any case, do not make use of that user co-routine instead, like we trigger from here, from take damage. We do that, then we check stuff, then we put it in a co-routine, but we go, we don't need to do this over here. So since we don't have like the particles yet, we don't have the Game Manager or score manager yet. We can actually destroy the break. We can do something like destroy game object. So this particular game objects where this brick script is sitting on gets automatically destroyed whenever health is lower or equal to 0. Now, we just need to take care of that we are triggering take damage with the ball. And the ball of course, has to react completely corrected this point. But that's what we're going to take care of in the next video. 16. #16 Destroying Bricks: Welcome back to the course. In this part, we want to take a look into how we can take the actual damage from the ball whenever the ball hits the break. To do that, we need to go into our boss gripped the because the ball is responsible for doing damage. So whenever it hits something, we want to get the component of type brick and see if there is one. And if that is the case, we want to trigger whatever we found over the detect damage function. So in that case, we create a new Boyd on collision enter. Make sure you type this 100% correct. On collision enter takes a condition as a parameter. We're going to give it a name. We can limit cURL or just collisions or whatever you please. And like OnCollisionEnter now can whenever it collide something. So in this case, if the ball collides with something, we can try to grab a bricks gripped, even if we are hitting a wall, we try to grab a brick script. In that case, we can say we create a new brick, a local brca1 variable. We can just name it be or also just brick was a litmus small letter B. And now we want to grab the component from the collided object. So it's a collision dot game object that gets components open-close triangle brackets of type, break, open, close parentheses and the end and close the line with a semicolon. Now the wall as an example of the parallel, they don't contain a break. And since they don't contain a brick, we need to check if we got a break. So if break the small break, the one we just tried to get is not equal to no means. Not equal is like we are. And we didn't find anything, so we didn't, we haven't been able to grab a brick component, a brick scripts from whatever we collided with. So this stays null or empty. And if it is not null or empty, then we want to talk to the script we were hitting. So in that case, we can just say bricked up take damage. Since that is a public function. And that's everything we need to destroy the break. Now, when we would hit something with our lead, say ball over here like this break at this point, we let the compiler random forget to save. If we now would head something like the ball will hit the break, then we go and destroy those brick from the sea. As you can see, since we still have the problem that the ball is not bouncing away from this rigid body. We go and get rid of it. So we go over here to rigid body itself. Since we have that in scene, we go and go to this little three dots and say Remove Component. But since that is a little prefab, we now have to apply the changes to the prefab as well. And unity to canine teeth in which I'm using. We do have this little overrides panel and we need to apply all this content. We need to override over here. So if that doesn't work for you, you can also go to your Prefabs folder, select jelly branch, and if possible or necessary, go to open prefab and then you can delete or get rid of pieces over here and also manipulate them. Once you are done with that, go to the hierarchy panel. And so like this little arrow, and you are going back into the normal C. Now let's test out again. Let's see if we can get rid of this break. And if we get a bounce, pretty good. So I would know Go and duplicate this multiple times. Of course I'm lazy and I don't want to make the wall game by hand. We're going to take a look into this later on. And I press Play and try to get rid of all these bricks over there. You can see all of them are completely destroy table based on however we hidden overall. Pretty good. So now we don't have any Brixton. Usually our game would be over. But since we want to learn even more, we want to take a look how we can automate creating John rubrics for our scene with some kind of a coding, let say, Yeah, behavior over there. But before we're going to do that, we want to make sure that our ball is getting started over on to the panel. And whenever we press a button that we're going to start that journey was the ball. And until that point, we wanna make sure that our ball sticks to the actual panel. That's what we're going to start with in the next video. 17. #17 Creating New Balls: Welcome back to the course. In this part, we're going to start to work on the game manager, as well as how we can put the ball onto the pedal until we suited. First off, we need to create a script. The script has to be called. Well, it doesn't have to be. But I'm going to name mine always Game Manager because this GameManager text track or keeps track of everything in the game, score, life's breaks, as well as anything else. That's why it's for me, again, Manager, you can also name it game logic. You can once again call it whatever you please NYC. Please open this one in MonoDevelop or Visual Studio or whatever you are using. First off, we're gonna get rid of starting update since we don't well, make use of them yet. What we first wanna do is we want to make sure that the game manager is a singleton. So we have full access from anywhere in the game, from any who in the game. So we create again a public static Game Manager. We're just going to be again the script name and call that instance. We can also name this whatever we want to. The wide name is going to be just the name of the instance. In awake, like wide awake, we want to say as always, instance is equal to this. So now we know that we have a game manager instance, which we can talk to at any time, at any, at any way we want or need to. What we now want to have as a possibility to create a new ball. So I'm gonna do some command. And what I also like to do sometimes is just pulling some dashes and here then and actually yet choose to design a bit the script so somebody is able like if anyone else is going to access it and just put some command lines like this one over here. So everything about creating a ball goes into this area and everything above it are like any other functions or probably just accessors and so on and so forth or the other methods. And so you can also do that. You can put something like that in between if you want to, you don't have to. So we want to create a new ball. So we need to first create a new function which probably needs to be public. So we have access to it from outside. Like whenever we lose a ball, then can we can talk to the game manager and say, hey, we need a new ball because we lost our last one. Please take care of that. And then it doesn't work as well. Then of course we don't need to create a new ball, probably doesn't even need to be public one, let's keep it private for the moment. So I name this group create ball or new Boys, whatever you please. And in here we just want to create a new game object. This game object of course, is going to be new born. And we need to say we want to instantiate this ball. But we have a problem. We have a problem that we don't have access to a nipple prefab, so we create a new one. And here we just say public game object, ball prefab or just ball up to you. So meaning, we also need to have a prefab which we can instantiate. And here in our instantiate method, we just say ball prefab. So we instantiate that from the inspector of late on just from the Prefabs folder. Now we need to transform it to the current parallel position. So we have our panel pedal is. We wanna make sure that we reposition our ball to this and lifted up a bit. So first off, we say newborn daughter transform dot possession is equal to. And now we need to find our pedal instance. So we say pedal dot instance, dot game objects, dot transform, dot position. And we add or lift the ball up by 1.5 in the y axis. So is say plus new vector two or no in this case vector three. Of course we are in a 3D game 000 and the line with a semicolon. And over inside the y-axis, we want to put 1.5 f because the sphere we are currently using has a size of one. The pedal distance from the center pivot point up until the, the actual squares half a size. So we want to make sure that we also have a little gap in between those two. So a gap of 0.5 units in the end. You should not go lower than that because otherwise the ball reacts to the pedal whenever we create it. That's why I lifted up slide but higher. You're going to see that in action a bit later. So the next one is I want to send the ball to be per child object of our paddle. So it's a newborn dot transform. Dope sets parent, I wanna set the parent object of the board to be the paddle object. In that case, we're going to say pedal, dot instance, dot, game object, dot transform, because we always need to set parents to be biased on the transform, not on the game object, not on the position that tends to be part of the transform. Finally, we wanna make sure that the ball not moving over royal, so it's not reacting to any rigid body stuff and so on. So we say newborn dot gameObject dot gets component of type rigid body. And we said Is Kinematic to be equal to true? Is Kinematic means the ball does not react to any physics at all. And the final step is we want to add the ball to a boil list so the game manager always know how many balls are on screen. In that case, we're going to create the list first list. And this list has to be, has to have a type. And this type, in this case it's going to be a game object type and we're going to name this ball list. A list is nothing else than an array in which we can store multiple objects or integers or floats or anything else or even classes. Now we need to define that this is going to be a new list of type gameObject, open, close parentheses, and close the line with a semicolon. And whenever we create the ball, we'd wanna say ball list dot add. So we want to add something to the ball list. In this case, it's done new ball. Don't forget to hit Save. And now we just need to trigger that and see if that works. To trigger that and test this out, we can simply go and create a void start method was a big S and the beginning pretty much important as you already know. And we can just say, Create ball, open, close parentheses, and close the line with a semicolon made on. We're going to go a step further with that. But for the moment, it should be good to go. Once the compiler is done running, we need to create a new seizure, a new game object, and name this one game manager. Each of these managers, I want to see them easier in my hierarchy. So I'm gonna create another empty one. And I just make up some dashes, something like that. So I can say hierarchically. So this doesn't depend on any position. You can reset this to 0, doesn't matter. We don't need to see that, but we can now see Game Manager and other objects easier when we have some, let's say, separators in our hierarchy. If you don't like it this way, of course you have other possibilities to make this one visible but earlier or a bit easier. Maybe you can put special an at symbol in front as an example. Or some people do two dashes to see stuff easier and so on. So all of that is completely up to you on the game manager object. We wanna drag the game manager script and we need a bowl prefab. In my case, I'm gonna take the ball from the scene. We already have and put this first into the Prefabs folder like this. Then we go to the game manager and make sure that the ball is going to be inside the Prefab. Now, I get rid of this ball over here, which we currently haven't seen. And I press Play. When I press play, my ball should be 1.5 over the actual pedal, and it should be part of the parallel. So when I move the pattern right now because we set the parent object to be this one, you can also see that the clone of the ball is part of our paddle object. That's what we want. So next time we go further and here we want to make sure that when we hit space, then the ball is able to leave the parallel. Of course, we can also use any other buttons over here. Don't forget to save your scene. And we're good to go. 18. #18 Releasing New Ball: Welcome back to the course. In this point, we want to go and work furthermore onto the ball as well as on the GameManager. So whenever we say hit the Spacebar on the keyboard or any other buttons you prefer, we wanna release the ball into the direction we want to bring it. So we need to take care of the ball in one place and on the Game Manager for waiting for all the possible inputs. So in that case, we're going to open our game manager script. First, we need to create two functions. The first one is, I'm going to name this void star, that ball. Which just triggers if we weren't hitting something. We don't really necessarily have to make use of that, but we wanna make sure that everything works fine. And here we laid on, just talk to the first ball in our ball list, which is going to be the one which has been created. And we need to check, of course, if there's anything inside, and so on and so forth. And of course, if the ball has been started already. So we now need to go, uh, between the ball itself, enter Game Manager itself a bit back and forwards. And game energy. I also want to create the update loop. Again. We need the update loop to get input data. So we wanna request if we are pressing the space key or you can once again take any other key you like. I'm gonna request if input don't get key down. So if somebody presses down the key, now I pass in the key code dot space. So if somebody presses the Space key on the keyboard, then I want to do something. But I also want to check if we have at least one ball in our ball list. So we say end bar list, dot count as bigger than 0. If that is the case, we want to do something or actually we want to start the actual ball. But before we want to do that, we want to make sure that we really have a ball which is not running already. So we can also put this into this if statement, or we go further one step, like into this next line. So we can literally put multiple if statements under each other or we can make use the end or, or operators and later on if necessary. So first things first, once again, we now know that our ball is dot count is bigger than 0, which is good. So, and also we want to make use of that. We want to make sure that ball lust is not easy, like the first item in the list is not 0 or not null, so we haven't lost it on whatever has happened, as well as if the ball has not been started. And if that is the case, we want to start the ball for the moment. We'll just calls Dot ball of here. But we want to request a football has been started. To do that. We go to the ball and give it some possibilities to check that. The first one is we want to implement a boolean for this particular or for each ball. A boolean only returns a true or false if something has happened. Even not, I'm gonna name this one ball started. And we need to have a function which our ball can get requested that. So in that case, a public function. This public function is of type bool. It just returns if a ball has been started. So is type in ball started as the function name? And then here, as you can see, it's not a void type, but the bool type. So that means every different type then avoid needs to request a return vector or return argument. So we wanna return if the ball actually has been started. So we return literally this Boolean. Why do we do this? Because we do not have to expose this Boolean and we don't have literally write access to it except internally over here whenever necessary. Also in ball, we need to create another function. In this case of type void, when which we want to start the ball, means we need to create this one as being a public one as well. I'm going to name it also starred the bolt. To start the bowl of here, we first need to check if we haven't started that ball yet. So if not, both started, means only then we are able to start this particular ball over here. Otherwise, we just return out of this function or we just don't perform anything else. If that is the case, we want to set our RB dot is command kinematic back to false. So we want to make use of rigid bodies again. Also, we wanna go and add initial force. And then k's are going to take the RB dot add force from the start method. I hit control X to cut it out and bring it over here. Also, I wanna do like a diagonal initial force. So something like inertia force, inertia force comma 0. So it goes on x in the positive direction or to the right as well as over here. If you want to go more fancy, you can also take the distance from the camera to the current, let say ball or pedal position. And if we are like one to the right, we can also say We want to bring it more to the right, otherwise, more to the left. So literally as we already have done, like with the actual pedal position, like where the bow ball bounces away from. Next step is we want to set both started to be equal to true. So we now know that this ball has been started on. We are not able to restart it or started once again. And the final step is we need to a deep parent does both from the pebble. So we need to reset the position of the parent or we need to literally go out of the parent but add to the world, back to the world in this case. So we say transform, don't parent, or in this case set parent. We want to set a new parent and we want to take the pedals parent. So in that case, since we are currently part of the parent, we're going to take our own. Transforms parent, which is the pedal. And we want to choose the parent's parent, in that case the world. We could also go and say paddle dot parent would be basically or peddled dot transform dot parent would be the same as transform.py current, which is the paddle and the parent of the parent or the parent of the panel is going to be the parent of the world or is going to be part of the world. So which is like the absolute or the maximum absolute paddle parent in this particular case is. We can once again also do some commands over here like D parent or parent. And back to the world. Because we want to move in world space and not in peddled space. Even if that would probably something interesting you can look into later on. But we don't want to do that. That's good. So now we can go back to the game energy and call all these functions. Now, first off, we want to check if in our ball list the first item and number 0 is not equal to null. That's just in case it doesn't have to happen. But we wanna make sure that nothing strange happens. Also, we want to check if our ball we currently have at this position has not been started. So we first of graph bore list the 0 element in that list of the first item in the list. And we want to get its component of type Born. Once we do have that open close parentheses, we wanna request Ball started those parentheses again, and that has not been started. So we want to return a force over here. In that case, we put an exclamation mark in front of the complete line over here. So if the ball list get component boy, has not been started, so that's what the knot is going to tell us. So we actually get a false in return from the ball. Only then we want to start the ball. So we're gonna put another pair of curly braces over here, going to take the dodgeball function here. And we're good to go. In start ball, we literally only talk to our ball lists as zeros item. So we say ball list in square brackets, 0 dot. And in here we want to of course go and get that component again of type of ball, open close parentheses. And now we say, we want to start the ball open close parenthesis again, and close the line with a semicolon. If you don't like the structure, if you don't like to have a stock boy function extra over here, you can also take this line of code of cause and brings us directly into this area. Basically bows works doesn't really matter at all. I just thought it might be better in case of structuring. But once again, all totally and completely up to you. Don't forget to save every script. Don't forget to save game and, And don't worry, even ball if you don't, haven't done yet. And let's go into test this one out. So whenever we now go and press play after the compiler has run and everything is fine, no arrows in the console. We're going to move left and right. And whenever I hit space, I should shoot the ball like into this direction, anywhere there. And we should have a game play running over the wisdom initial force of 600 by 600. Of course, the ball gets faster, slide a bit depending on where it comes from and goes to. And we should have a rather nice game play already inside. And also you wanna make sure that you don't get any errors whenever you hit the ball and hit the Space again, that you don't get any arrows here as well. Once again, don't forget to save if you have done any major changes in the scene. And see you in the next one. 19. #19 Tracking Bricks: Welcome back to the course in this problem, we want to go further into the game manager part because since we know have the Game Manager, we can also put our breaks, which we laid ongoing instantiate directly into a list of GameManager. So we can take care of and keep track of how many jelly breaks are going to be inside our game. For testing purposes, I just drank one jelly brick enter the scene or maybe two, or maybe three. So we can take 100% look into how they look and how they act, and if everything works completely correct. Once again, you don't have to do this. It's just for testing purposes. Let's open our game manager script and let's take a look into it. We don't need to touch these. What we now want to do is we want to create a new list which keeps track of all the bricks, basically the same as we did with the ball list of here. Gonna copy this complete list line. I'm gonna make another list of here and name this brick list. Now we want to add all the bricks in the scene whenever the game starts, whenever they get created into this brick list, but we don't want to expose the list of here. We want to create some functions. For that particular case. What we can do is we can again do something like this, like a command line and say something about breaks at all. So just breaks. So everything about bricks gonna go and land over here. Once again, you can be super design heavy over here. You don't need to do this, but probably it's something which helps you out later on organizing scripts if necessary. So we have two things we want to remove and add a square actual break. So we'll create a new void function over here, which we want to have or wanna trigger when we want to add a brick. We're gonna request one argument which is a type of game object. And of course we give it a name, something like Brick. If we wanna go and add the brick, we need to make sure that this one is a public function. Otherwise we don't have access to this function. What we wanna do is over here, we want to say brick. And, and what do we want to add is the incoming argument called Brick. There's one for removing. It is a bit more, well, basically it's the same, but also we can also check how many bricks are still in the game to get the win condition running. So we can say public, void, remove, break. And of course, as an argument we're going to take another game, objects break, end and here we just say the opposite. We say break list, dot remove. And what do we want to remove is the actual brink. Then of course we want to see how much are left in this brick list. And what we can tell is for the, say, winning condition are going to make another command over your condition. We're gonna, we're going to be able to check if the brick list dot count is actually equal to 0. So we say equal equals 0. If that is the case, if there are no brakes left, we know that we want. So we can like a debug or print a message directly into the console. We can say print, open, close parentheses and quotes. We're going to say, you won. Of course we can do put later on way more better Logic Intuit live, showing a score, showing how, how long does it took, what was the highest score ever, and so on and so forth. But for now we just want to take care of the bricks over here. So now we need to make sure that our breaks are reporting to Game Manager whenever they get created or destroyed. So and here the stone function of the brick C-sharp script. We're going to talk to the game manager. So it's a game manager dot instance dot add brick. And what does the brick we want to add is actually this object, this game object, but this doesn't work. So we'll just say the stock game object. And as you can also see, it's getting grayed out. So it can be simplified to be just taking the game object wherever this brick script is sitting on. Don't forget to save the script. And the same now can be done if we don't have any health left. So I report to the Game Manager that we need to remove the break. So actually I'm going to copy this line, bring it here and say remove brick. And we want to remove this particular game object from that list from the Game Manager. Lets try it out and see how it works in action. First off, we open up our game and just scraped after the compiler is done running. And we go into the top right corner, there are three little dots where we see normal is checkmarked. You're going to want to go into debug mode. So we see a bit more infos as well as the brick list, as well as the boldest. I do not go and maximize on play. So I can see all the components running over here in the game manager. So once I press play, you can see that our ball gets added to the ball list. And all the three bricks we currently have and seen. So jelly brick 102 in this case, all of them subscribe to the brick list. If I now go and destroy one of these. Gotta pause the game. You can see that the jelly brick got removed from the list and the list now creates the ore actually makes sure that it resizes automatically to the rest of the bricks inside. Same here you can see now it has only one jelly brick laughed, and whenever the last one gets created, the brick length is equal to 0 and we get reported. You want. That is necessary light on whenever we have like a couple of bricks into the scene, we need to check if that works. We now have the possibility to see that everything works as it should. So we now can also grab score whenever we actually destroy them, as well as we can check this particular jelly brick, for example, I go back into normal modes so we don't have too much crowded infos. And go, let's say, and make this one jelly brick. I wanna make this having a health five. If it is a board number, you know that it is part of the actual prefab. So do not overwrite this otherwise you override all the other templates or actually all of the other relative prefabs. In this case, when I now press play, and I need to go and hit this 1 first. So we take a look into the current health of this particular break. You can see one Godhead and this one now has lost one health to health. And now three heads and one more or two more are now necessary for this brick to be destroyed. So we see that the health system also works. And now we have one because this brick didn't had any life's left or any health left at this point. Pretty good. So we now can literally go and change this health block back to be one. Nothing fancy at all. We don't even need to change that, we can just get rid of it. But for this part, we're good to go and we basically have everything done. We probably go and need for a game like that. But of course there's more to come. 20. #20 Lifes 1: Welcome back to the course. In this part, we want to take a look into how we can actually lose life's analyzer. Basically, when we lose a ball, do a through a dead zone, we're going to talk about this as well. Then we want to lose, or whenever we lose a ball, we will also lose a life. Beforehand. We need to trigger or actually set up something like a system which takes care of life. And of course, our game manager is the best way to do it because he's always here. We can easily access it and so on. So let's open up the game manager and let's take a look. So first off, we need to have something like an integer which can take care of our lives. We can do sense just any value. Like we start with a level with three lives over here directly inside the variable. Or we can also do this like onStart or whenever we need to, let say reset again. So for resetting again, we can literally create a new void reset game. So reset game basically can also be something for like restarting again. So literally, we just trigger that from the start function and can set our lives to be equal to three. And of course laid on like gonna make another command over here we update our UI, our user interface. Whenever we have like a text somewhere which represents the amount. So whenever we reset a game, we also want to create a ball. So literally we could take the create bowl functionality from here, bring this into the reset function. And here we only call reset gate and everything of the will of course, trigger. So now that we actually can take care of how we start with life. So we start with three lives. We now need to find a way to remove life's not going to make another nice command part of here. So I just copy this line and take care of life's over here. So what do we actually need is a way to remove lives and reset the game if necessary or whatever. So to remove life, we create a new void, remove life, open close parentheses, and then open close curly brace. So whenever this is called and we call this later on when we are losing a ball, then we want to make sure that the actual remove lice takes care of that. First off, we wanna reduce lives by one, so lives minus-minus. Then we want to also again update the UI at this point. We don't have UI yet, so we don't care. And then we put the loose condition over here. So News condition, the loose condition is whenever the game hair or whenever the player has like no life left. So if life's is equal to 0, we can also use smaller equals 0, as we did with the health of the bricks. Basically both works. So what we're gonna do over here is since we just said by whenever we have like no bricks left, we said a print message that we want. We're going to put something like a print message over here, just a simple game over. Just printing that into the console will show us that we are able to remove these lives. Awesome. Now we need to have another function, which is going to be a public function which we can access from outside, like from the dead zone or from the ball, depending on how we actually structure that. So we want to name this lost ball. We want to know which ball that we lost. So we can say game object ball. So we can also remove it from the ball list. As we already did with the bricks. Like whenever we lose a ball, we want to remove it from the ball list. And so also, we can say, okay, if there is no ball anymore left and we can create a new ball if we have enough life left. So first off, we say ball, list dot remove. And we want to remove the ball, which ever we pass it. Then we want to destroy the ball because, well, we don't need it anymore in the game. Then we want to check how much lives we have bluffed. If we have or actually first, how big the actual level is going to be like the big, how big the ball amount is currently after we are destroying that particular ball or actually deleting it from the list. So we want to first check, is the ball list empty? If the ball is, is equal to 0 because we can have later on multiple balls, then we wanna make sure that meanwhile we have 0 left only then we lose a life. Otherwise we can play with all the other balls we have left. So ball list, dot count, we want to check if that is 0. If that is the case, we want to remove a live, so we just call removed life over here. Don't forget to save. And now since we want to remove a life whenever we lose a ball, we also maybe have no loose condition at this point. And by the way, if we do lose at this point, we want to return over here. Returning means we are leaving the complete function at this particular point. And we do not perform what's coming next. And what's coming next is of course, we want to create a new ball at this point. And we want to reset the paddle position. I'm gonna put just for the moment, reset pedal position because we don't have the function for that one yet. So that's everything we need to do to if we are losing alive. Pretty good. So for the moment, everything for the app is going to be done. Once again, we just need to put in some user interface later on to show the player how much we do have left, as well as we need to reset the pedal position whenever we lose the ball. And the next video we are going to create the dead zone. And how do we trigger the lost bowl function? 21. #21 Reducing Lifes: Welcome back to the course. In this part, we're going to take a look into the dead zone. The dead zone is literally the lowest or the bottom panel or border of the here. We're going to have to change that a bit. And also we need to add some code to it. So the code is rather simple, but beforehand we're going to create a new C-sharp script and call this one dead zone. You're going also known as whatever you like and place. And of course after the compiler than running reopen this one in MonoDevelop or Visual Studio or whatever IDE you're using. One's dead zone has been opened. We get rid of stuff not dead since we don't need those. The only thing we need is a trigger event function. This is near named On Trigger entered. So whenever something enters this trigger, we want to react to it. We want to react to it only if a ball enters this dead zone or the trigger. So first we need to check for a collider. We give it a name, see well, so we can ask for it. So what we wanna do is we want to see if it is the ball which currently triggers this function. So we say if cURL dot game object, well we don't even need to have the game object over here. We can just compare a tag and the tag we request as of course, the tag ball. So now we compare the tag of the incoming collision. So if there's something else like a pick-up or so it will be ignored. But well, later on we probably go for and check for pickups as well. Like whenever there's something falling downwards and so on and so forth, which we can loot. And to trigger another event like a power up or power down above or debuff, however you name it, then of course we want to check for that as well. So we destroy them whenever they literally reach the dead zone. Or maybe whenever they leave the dead zone. We're going to take a look into this later on when we want to call it now, when we know, okay, there is a ball are currently hitting me. We won't unload our game manager instance. And we wanna say, okay, we lost a ball because that's the function which we named it. And we want to pass over the current or the actual colliders game object into the function. Don't forget to save. So once again, we check for other triggers or for other colliders to trigger the dead zone area. We check if it is a ball and if it is a boy, we're going to call the lost boy function in Game Manager. Again, the lost function says, okay, we take this whatever ball has passed by and remove it from the boiler list, we destroy the ball. And if we have like no ball left, then we remove a life. And of course, we're going to go forward. Meaning when we remove the life, in this case we just say life's minus-minus. We're gonna do a check if we have life's left, if not, actually the lifecycle to zeros and we just return. Otherwise, we're going to create a new ball and the new block creation, we already talked about this as well. We just put it on top of the pedal. Only thing we don't have at the moment is putting. Resetting the pedal position. But for the moment that's fine. Now let's create a trigger. So I want this bar over here being my trigger zone, my dead zone. You can also rename it over here being dead zone, but actually it doesn't matter. So we keep it as bottom border. It will order resize to well, to the frame here as well to the boundaries of our camera screens. Or it doesn't matter how big or how small our game scene is. And what we now want to do is your box collider on this bottom box, we need to set it to be is trigger. We don't need to add a rigid body component to it because the ball contains that rigid body component. Meaning if the ball hits that, it will notify. If the boy would not have a rigid body, then we need to pass in a RigidBody component onto this one. But once again, is not necessary at this point. Also, I want to attempt this, so I give it just another material. So I just create a new material and I make this one red and maybe semi-transparent. So I create a transparent rendering mode. Go here, make it red, go down with transparency just a bit, and put the rat material onto the bottom border in the scene. So we can see slightly is ruined as well as maybe we don't even need to have this this much visible. Maybe you can even reduce it a bit more later on. We can also play around with the visual effects and all the other good stuff, but for the moment it's not necessary. So from now on, the ball will fall through this area. And what actually will be able to enter this area. Once that happens, it will trigger the event, the entree eager and turn. And then we should be able to tank, are actually gets a new ball onto the pedal when we lost it. And we should also take a look on to the game manager. We go back into debugging mode. So we can also see the life's integer over here, which is grayed out because it's private. And now we press play. We should start with lives of S3. So as you can see, we now have three lies, we have three Janet breaks and so on. If I know, shoot the ball and let it fall down, hopefully that happens. Well, as you can see, nothing happened. Why is that the case? Because the bottom border does not contain our DeathZone script. So once again, I just shrink stuff together, go to scripts and add the dead-on script to my bottom border. Pretty good. Now we go back again into the game manager. You have seen that the ball is able to fall through. I go here, shoot the ball, tried to get out of the way. And what you have seen now is whenever the ball touches the dead zone, the ball gets destroyed and we get a new board directly on top of our paddle. Also, the Allies got reduced to two, as you can see over here. So we can basically do this multiple times until we have like no life left. As you can see, the only thing we don't do, we do not reduce the actual amount. What you now have seen is that the lives is now at 0. We get the print message, we are game over and we do not get a new ball onto our parallel. So in that case we would just go and show some on-screen message. Sorry you lost. Like nice user interface design and so on and so forth. That's later on anyway, is up to you. But that's what we're going to go and get four and 10-week have probably two button, something like restart game or just go back to the main menu or to the level select menu or whatever. 22. #22 Reset Paddle Position: Welcome back to the course. In this point, we want to reset the panel to its, let's say start position or any position we think is going to be the correct one. So please open your pedal script by double-clicking, or you maybe have that open already. What we wanna do is we wanna create a new function which is taking care of everything, boys doing the reset. So we say void reset. Basically, we want to reset the petals position. So if you like to name it reset position or recent pedal, completely up to a year, probably reset pedal is better since we have to call this from outside. And since we need to call this from outside, we want to have it a public research cuddled void function. What we wanna do is we want to set the transform.py position to be wherever we want it to be. So we say transponder position is equal to a new vector, three. And now we're going to pass in the unnecessary parameters on x, y, and zed. Also, no matter how high or whatever our current resized size is going to be, we want to call resize x scale based on whatever our new size or current news size setting is going to be. So we're going to also reset this one as well. So we say resize. And N here we're gonna pass in whatever new sizes, something like that. Now we want to declare what is the actual x position over here. The x position is always the center of the screen. So we can take the x coordinate of the main camera. So we say camera main transform dot position, dot x. In the y-value, we want to have like wherever it is on its current height. So literally we don't want to change that. So usually, or typically, we could say something like transform dot position dot y. And the last one is the z axis. And this is going to be wherever the zed axis is. In our case, we always keep that as position 0. Now, whenever we need to reset it, we just need to call it, meaning whenever we lose the ball. And since I'm a pedal, has a singleton which we can simply access from anywhere. We can call that. Now from here, our remove life function. So we create a new ball and wherever our pedal is, we wanna say pedal, dot instance, dot, reset, paddle. We don't need to do anything but calling this function. Don't forget to save, Don't forget to save your pedal script Control S for quick safe. And then we should be good to go and let's test it out. So once again, I go and any corner, and whenever we create a new ball or we lose one, we want to go back into the center of the screen. And by the way, if you are not 100% sure in pedal of the start function, you can also go in and actually called the reset pedal function just at the beginning. So and since resize as part of reset, like over here, we can get rid of this piece at this point as well. So let's go and take a look. Don't forget to save everything. Don't forget to save your scripts, whichever you have changed, and let's get into it. So I moved to the side and shoot the ball and just stay here. What you can see now it pops directly back into the center. So it takes the current y position, the x coordinate of the camera. And the zed position is going to be wherever our Playford currently is. Any ways? Awesome. Now, we're good to go and we now have a rather, yeah, good work flow already. So we can shoot balls. We can lose balls. We can literally lose the game. We can literally when the game. But well, there's more to come since, well, we are lazy and we don't wanna set like all. And we'll bricks by hand even if we can, no problems at all. But when I want to teach you is how you can create a system which takes care of creating all this little cubes or all those bricks in a way you like to do it. And of course, automate tinting and everything else, whichever is necessary at this point. Even we can put in the health like how much hell's does each brick is going to have. Meanwhile, it is running over there. But that's content of the next coming videos because that is quite a huge topic. 23. #23 Quick Recap: Welcome back to the course. In this point, we want to quickly recap what we have done so far and do some check monks behind it and talk about this pretty quick. So first off, when we take care of or took care of that, we got a paddle and we wanted to keep it in screen, make it resizable, and even have some movement wizard by using some buttons. So parallel, the truly is done. There are some other things we're going to have to add to the pedal. But for the moment the basics are done so far. Then we were creating this order resize frame, which takes care that this is a screen resolution unrelated and keeps the borne blocking from leaving the screen. So we have that done as well. We created a game manager which has life's the possibility to win and lose a game by just a triggering the events, as we already talked about. Also, we had the bricks involved so there are currently haven't health, but they don't have the drops down like from power apps or power Downs. So bricks with health are done, but we do not have the actual dropdowns from this one. Next one is we want to go for on, we don't have a score manager yet, so we need to keep track of the score itself. And also later on when it comes to UI and probably new scene management, we're going to create a level manager which are able to load levels from the buttons. So we don't have that at the moment as well. Although we don't have any UI design yet which shows the score and the lives and probably also some other, let's say, graphic elements which we miss here as well. And also we want to go over into the level design seem to simplify stuff. So we can automatically create these little block arrays or block lists and you can call them whatever you please Like that you can design them to whatever and however you need them, based on each level, you can be super creative with all of that content. So since we have basically the necessary stuff is completely done, we can go for the level manager and the next one and the next as seen literally on the next video, as well as later on, the level manager comes later on as well as a main menu and stuff like that, which you can also design to your own needs. As well as the user interface design, which is kind of related to score manager, as well as to the life as I already showed you here. We're going to pull some text elements for the score and for the lives of a here you can also design that completely on your own, totally 100% only up to u. Also, we don't have any effects yet. The nine can maybe we're going to put this in the list for brick, destroying something like particle effect whenever we destroy a brick. So I'm going to make another cross behind that. So I just add to my initial plan over here. So these are the things we want to literally laid on go and take a look into. So I believe in the next video we're gonna continue with the score manager and probably blink some simple UI design into play so we can show the score, showed the lice. And yeah, that's nothing too fancy over there. And after that we can go for the wheel hard stone. So basically this is the advanced topic of the course. So please be prepared for that so far. 24. #24 Score Manager: Welcome back to the course. In this point, we want to take a look into the score manager. So I give it a new extra empty game object. I get rid of the debug mode over here, just make it a normal mode, giving it two dashes and just say score manager, just an empty game object anywhere in the scene if you want to, you can reset its position. I drag it between my desk line objects over here which are just empty, nothing fancy. Just to visualize things a bit easier. On score manager, we just need to create a new script which is containing all the content for the score management. So I named the script score manager and drag it onto the score manager object whenever the compiler is done. So put it here and double-click to open in MonoDevelop or Visual Studio. Once loaded, we want to go and get rid of the update loop since we don't need this. And here we also don't need this command line. The first thing we wanna do is we change the start method to be an awake method since we want to make this score manager singleton as well. So we say public static score manager, and we'll give it a name instance. Then an awake we wanna say as usual instance as equal to this. Now we have that. We also want to update the UI if we have one. So I'm going to make a command update UI. You're going to know in a second what we do there. The score manager has to keep track of score. So we need to give it some integer which is going to take or hold the current score. Also, we want to have a accessor function which is able to change the score whenever we get score. In our case, we're gonna create a new. And since we want to access it from outside, it has to be public void. And we just name it add score. And we now want to put in as an argument of a. Here's another integer which we can also name score. This means we can pass in any type of score and added to the current score. Meaning that whenever we call it, we wanna say current score plus equal the incoming score. This one. Now, whenever we have 0 over here, which we start with, and we add 50 score or 30 score for creating or destroying a brick, then the current score should increase. Also at this point, update BY meaning that the player sees, oh, I have Moscow now because I have destroyed a break. Now, let's create the update UI function. I just name it update UI. You can name it whatever you want, but do not name it update because the update loop something different, mono behavior-based. So I'm going to name mine update UI. And what we wanna do is we want to change text, like a text field which contains all our scores. In our case, we need to implement a namespace. Namespace is just something in which we have access to different, let's say content. In our case, we need to take Unity engine, wi namespace. This namespace contains texts, images, and other components we usually don't have access to. And that case, we can now add a text field so we can create a public text and we can name this Score Text. So this cortex will show our current score later on, on screen. In here, we can say something like as a protector, we don't really need that. We can say if current score is a score text is not equal to null, then we send them some text. I don't do this, so we see what's happening if we forget it. Forget it. So we get a console log error. To write a string parameters or any type of score, we need to say Score Text 2.txt, which returns or takes a string as a parameter. Now we're gonna pass in some quotes score, colon space plus, and now we take the current score and convert this to a string. Because later on we can also put in some formatting and which we can format the actual score text in the string. And the next part we are going to add the UI elements s