Unity Game Tutorial: Tetris 3D | Octo Man | Skillshare
Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
57 Lessons (5h 52m)
    • 1. #1 Introduction

    • 2. #2 The Concept

    • 3. #3 Unity Layout

    • 4. #4 Playfield Setup

    • 5. #5 Playfield Material

    • 6. #6 Coding Playfield Grid 1

    • 7. #7 Coding Playfield Grid 2

    • 8. #8 Coding Playfield Grid 3

    • 9. #9 Coding Playfield Grid 4

    • 10. #10 The Camera 1

    • 11. #11 The Camera 2

    • 12. #12 Creating The Blocks

    • 13. #13 Moving Blocks Down

    • 14. #14 Check Valid Move Round

    • 15. #15 Check Valid Move In Grid

    • 16. #16 Check Valid Move Update Grid

    • 17. #17 Tetris Block Update Grid

    • 18. #18 Check Valid Move Get Grid Position

    • 19. #19 Block List

    • 20. #20 Spawning New Blocks

    • 21. #21 Spawn Block Position Fix

    • 22. #22 Movement Input

    • 23. #23 Rotation Input

    • 24. #24 Movement UI

    • 25. #25 Rotation UI

    • 26. #26 Mini Clean Up UI

    • 27. #27 Reposition InputHolder

    • 28. #28 Reposition InputHolder 2

    • 29. #29 Moving Blocks UI

    • 30. #30 Rotate Blocks UI

    • 31. #31 2 Sided Buttons

    • 32. #32 Switching Inputs

    • 33. #33 Speed Up Button

    • 34. #34 Delete Layer Check Full Layer

    • 35. #35 Delete Layer Deleting Blocks

    • 36. #36 Delete Layer Move All Down

    • 37. #37 Delete Layer Bugfixes

    • 38. #38 CleanUp Random Start Block

    • 39. #39 Ghost Block Prefabs

    • 40. #40 Ghost Block Ghost List

    • 41. #41 Ghost Block Reposition

    • 42. #42 Ghost Block Move Down

    • 43. #43 Ghost Block Final Steps

    • 44. #44 UI Intro

    • 45. #45 UI Previewer Setup

    • 46. #46 UI Coding Previewer

    • 47. #47 UI Finishing Previewer

    • 48. #48 UI Score Layers Level

    • 49. #49 UI Calculate Fallspeed Score

    • 50. #50 UI Calculate Cleared Layers

    • 51. #51 UI Text Elements

    • 52. #52 UI Update UI

    • 53. #53 UI Update FallTime

    • 54. #54 GameOver

    • 55. #55 Game Over Window

    • 56. #56 Menu Scene

    • 57. #57 Conclusion Thanks

  • --
  • 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 Tetris 3D in Unity Game Engine.
We create the game so, that the player has to fill full 3D Layers instead of rows.

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 several Systems which will give us enough freedom to:

C# (Monodevelop)

  • create any Tetris like game

  • you learn about arrays functions, lists, variables and much more

  • access to other scripts the easiest way

  • resize the playfield automatically

Unity (2018.2.11f1)

  • create a Playfield of your liking

  • create Button Inputs to give the Player a way to control the tetris blocks

  • Create a simple Game Ove GUI

  • Menu and Game Scene and connect them together

Course Material

I provide:

  1. 5 white grafics as *.png for arrows and frames

  2. 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 Tetris 3D Game.

So what are you waiting for?

Let's make your dream game a reality!!

Level: Beginner/Intermediate
Video Course Length: ~6 hours 
Unity Version required: 5.6+

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 this little introduction video about how to create a Tetris style blocks three D game. In a unity in this course, you gonna learn how to animate things, how button interaction works. How did I a design, a complete Tetris game, but a bit different in this case. So what you gonna learn is how to handle the camera with the mouse, which is also later on good for touch input. We're gonna see how we can actually interact with the buttons directly and talk to game objects. We can also switch that to rotate this particular blocks over here and more how we place them also, how to show some kind of a ghost blogger which is representing where our actual piece is going to land Over here. We're going to create this little preview window where another camera is rendering that somewhere in the scene and you learn how to hide it. So it's not visible in our game scene Over here, we're gonna talk about score level and layers to become completed and how to interact with all of these. Are you? I elements We're gonna learn also how to speed things downwards so we can actually give the player the possibility. Toe, you know, play the game even faster. Once again, we can design like or you can design a later on. However, you want our blocks on your blocks to look like how you want to act with them and so on and so forth. And in the end, you whenever you're going to lose off course, I'm gonna do this product quick. We gonna learn how to create a little game over over here as well as bringing a possibility for back to menu. We gonna lock the selection for switch and speed up at this point because it has no impact anymore on we are able to go back to the bone main menu. In this case, if you are interested in learning how this game or such games are going toe work, how to interact was all of that stuff and how to bring your lower knowledge off unity even further. If you want to learn a bit more about see shop or anything else which you are currently interested in, feel free to join this course and become my student. I already have over 500 students which are taking one for my courses or even this one, and we learn every day. New content. So if you want to be one of these as well free, free to join the course and let's get started with learning how to create gapes. 2. #2 The Concept: Welcome to the course. This is the concept video about how to create a Tetris three D game in Unity engine. My name is Dr Man and I'm going to be your instructor for the next couple of hours where we're going to create a fully functional game based on the concept year some years ago, on some years old already. And let's talk about what is Tetris if you never heard of it. Now I'm going to enlighten you and Ted Rece, we gonna have a play field which is in the old versions most of the time in the two demon, or to degrade space and into this grid space. We gonna have the possibility to place some of these figures. You may know already or not. I'm gonna go a bit deeper on the concept in just a second. So we have this grid, which is usually just so X y coordinate grid where we need to fill in rows with these hair , Tetris pieces or Tetris blocks. So when one row is full, then we're gonna earn some points. The more rows you can ask a full full in one round, usually the highest. Ah ro amount is going to be for at the same time to be cleared, then you get the most in case of points. Also, later on, there's going to be some level involved like whenever you have getting, whenever you reach a specific score, for example, a specific timer has run out. The game becomes faster, like the blocks are falling down faster and so on. It's a forced to make it even harder, and in the long run, or in the end, you gonna make sure to get the most out of it. The most points you can reach whenever the top is reads, and you are not able to create more full rose than off course, the game is over. Let's talk about what we're going to create. First off, I gonna go on explain about all the blocks since we're working in the three d space. Of course, we're gonna have several year spaces or several things we're gonna need to take a look at First off, we want the player to give some movement with some arrows or any other types off buttons to manipulate the position off our axle block inside the grid. We're going to define later and which are going to explain in a moment as well. What we also want to do is want to limit that. So we're not able to exceed the grid itself. So we cannot leave the Playfield basically same four rotation. Since we have once again in this three d space, we gonna have thes l pieces can rotate in the Y axis and the axe exes as well as over the zad excess which is in unity, the forward access. Maybe I got the color's wrong here, but I hope you get the idea. You can rotate them clockwise or counterclockwise, so we need to take care of that that also meanwhile, we rotate. We do not exceed the playing field. Also, meanwhile, we going to do all these kind of inputs, like rotated around dragons or actually moving left and right up and down or forward and backwards also have a something which is called a force. We force the anti peace which is coming from the top, falling down once we force it downwards every now and then, like after a couple of seconds or whatever we please like as being a forced time to get forced down. Whenever this is not able to move anymore into the negative direction, of course Want to plant it wherever it is and however it has landed and we want to update the grid. So the grid knows. Okay, at this position where these small blocks are going to be, these are full spaces. So we are unable to do anything at this point except just checking for whenever our layer is full. Speaking of the layer, let's go up and see where what this game is looking about. We're gonna have a play field which we can later on define and its size like in the X y and that coordinate as well as we're gonna go get the blocks spawned and the very top off the playfield and then move it down by the explained force we also want to create is some kind of ghost stones or goes blocks which are showing the player the way where this oh answered the sport of this place where these blocks are going to lend. So to indicate even better, how this is going toe work or if it is fitting in ah specific yeah area, I would say. Also, we're gonna have the possibility to rotate to the complete play fit around itself. So we need to take care off this grid itself that it is always visible for the players. So no matter what directing is looking from, he will always see some type of a great to be at the bottom. Being the one of the wall types over there, we're going to talk about this as well. Also, we ought to resize them later on Bioko, depending on how you or how we set up the complete writ. So we can better visualize that and we'll do our calculations directly. Based on that, whenever we are able as a player to fulfill one complete layer with blocks like was a single blocks over here, then we gonna get a score. We get rid of the complete block and let the company playfield full downwards once So actually everything gets updated and everything. Witches, in this case in the second row will don't fall down in the zero on the first row over here , and everything else in the upper rose, which at wherever stuff is going to be off course, will fall down as well, and we have, of course, a game overstate, meaning whenever there's nothing more matching basically at it's a start position and is not as free space at the start position. We gonna make sure that the game is over. So depending once again on the falling speed, this can be very troublesome. We're gonna have, since we are creating some kind of a mobile input. Of course, we're gonna create some buttons like where we can switch. Where's one button where we can switch if we want to move the stone or even rotated as well as we're gonna do. Maybe a second button, which is going to represent the full speed, meaning we can set it one to raise a high whenever we select this button even once. So this stone is going to fall in its highest or fastest way, falling down and land wherever it has landed. So we get a new blob at this point over here. So whenever we have done all of that and the concept is now clear, of course we're gonna do some seizure coding. I mean, a lot of seizure, according over here. In that case, we gonna talk about variables like flutes since and a string eso inter just bowling's floats once again. And, yes, string variables, which we take to compare things. Are we going together to war forced off it when sometimes also need to round up or down. Some year flowed variables to be string variables and so on and so force. We also call Look into a you asked a three dimensional array. So since we are working in this three d space, we do not just have this type like a two D array, like a two D X and Y Coordinate was ever sad coordinators of the deaf like off the playfield. So meaning we need to have a three dimensional array where we're going to store. The information's off. The transforms off each of small blocks over there, so we can actually compare if that layer is full, like every year, every transform and there's array gonna have a spot taken over there. Then we know. Okay, we have a full complete layer over there. Also, we talk about four loops and for each loop, since we are going to look through each of the small blocks at every now and then whenever we gonna place them whenever we check if that is a possible spot, like whenever we're moving it left and right up and down wards or even rotated if there's a free spot and if there is no free spot. Of course, we want to make sure that we don't do the or undo the last input. So there are two possibilities. Just don't do it or undo the last stop over here. That's what we do in this for each lives on four loops we most of the time it rates rule a the array itself. So the grid array itself to see where we are currently at and check it out. Also updated. Meanwhile, the rays runnings room. Also, we're gonna go and once again take the four each lives to it rate through all the child objects off each of the blocks or block sense a name it, whatever you want. And the last one is. Of course, we're going to create several functions which are helping us to do the calculations inside the grid as well as dual the yet deformations like we're going to create a function for the pure movement, which is rather small. You will be impressed about that, I guess. Same for rotation. We just sent in one vector. And just check if that vector is able to do stuff. Also, we have one function which is going to do the force down and so on and so forth. All of that is going to be part of the course. Also, once again, we're gonna automate the are the playfield size meaning we gonna create some kind of grit over here with just planes. And we're going to scale this planes based on the inputs off the size we wanna have in our grid. And according to that, we want to automate the playfield size, meaning we automatically automatically set up the erase about the size as well as we gonna Yes, set the material, Toby Tyler Herbal and being always a square. And based on once again, whatever these inputs off the integers in our grid or in our actual great set up are going to be probably we gonna do some game over screen. Maybe we also do something like whenever we have reached this point, we're gonna do some animations like we may be filled the complete grid was blocks and then just give a big game over screen into the screen. So the player knows. Okay, this was my final screen. Probably. We also implement some timer. Even if I don't think that is necessary. Maybe we're gonna talk about levels as well as once again. The based on the level we're gonna go and, yeah, choose or decrease the full time every now and then. All of that, and probably more will be seen in the course. So I hope to see you in the course and yes, start to create this time off game. 3. #3 Unity Layout: Welcome back to the course in this part. I just want toe talk about the unity. Lay on to credit quick. Which means whenever you're new to unity, no problem at all are gonna do just some rez. A simple cover up over here. So what I want Teoh actually explain to you is how you want to set up your screen over here . So basically want your layout? Should be about we need to see is three things at the same time, or at least four. So usually unity start with the scene view and the game you all next to each other over here, the top. And so you're gonna see more or less more off your screen and so on. And so force what I want to end Carajas you is to do it so that you always see the game and the senior at the same time. So whenever we do changes here, we can control them in the game view. Also want to encourage you to send your aspect ratio? Never, ever work in free aspect. Make yourself sure. You work in six by 10. 16 by nine and nine by 60 Norton by 16 if you don't have nine by 16 and 10 by six, and you can always press on the plus in just here include the aspect ratios for that. What you also want to do is you want to drag your console, which is going to be necessary later on for programming and debugging purposes, as well as when we do any typing mistakes or anything else. We want to see all of that stuff listed top to bottom over there, so make sure you always see the console next to of the seen World game view. Why I say that is rez. A simple let's assume we are going to be inside our game view of a here. We never see if that's something coming up inside the corn, so we always need to switch back and force whenever we are changing the mode. This is absolutely not helpful, and that's why it is necessary, for you are actually a better workflow in total toe. Always, whenever you do something with coding, see the console at the same time, Ecstasy or the other ones. This one well, you also need us the inspector window, so whenever we want to do some quick changes into our scene. For example, toe the main camera over here. We're gonna see always to inspect the window. Where you going? A place that is totally up to you if you want to have this on the left side up to you. If you want others on the right side, up to you, make sure it takes the complete screen spaces. So you have more visual overview over the inspector and all its components, or at least a better overview of that. Also make sure that you always see the Project Window worlds not always necessary to see it . But it's easier to navigate. For example, when we need to drag something from the project window into the hierarchy window, then it doesn't make sense to have the project window over here because we have the trouble to get anyhow into the hierarchy window. So make sure you have that, or I am extra as extra field. So Inspector Harry G. Project, as well as game seen view as well as the consul the here separated for the best. I would say the best year workflow on the our side over here. Once you're done and happy was your set up and you think you can work like that? You cannot go in the top right corner and safe your current layout. I have mine said here to be Octomom layout, and I always start new basically in this particular layout. If, however, I have saved this before. 4. #4 Playfield Setup: Welcome back to the course in this part. We want to start to create our playfield. So the playfield is deter mined by some planes. But these planes are not just flying around anywhere. We want to make sure that we visualize them based on the size or Playfield. To do so, we're gonna first create an anti game object. And we want to make sure that we zero this one out by just pressing on the little G. Arkin and say, reset, it will automatically land on 000 on the world access. This is important because we are going to work on that for quite some time. Also, what you want to do is you want to rename this one to maybe play field or grit or whatever you please like totally up to you. Well, we know want to do is based on a play field. We wanna have a bottom part and then some walls which are representing or playfield grid, as I already explained in the concept video. So we go there creating news, really object, right? Click on the playfield whenever it is selected, toe automatically make child of it and we want to create a plane. This plane might take a second to low, depending on the unity version and sewn into force. And I can see it center to automatically to our game. Object. But we want to do later on. We want to automatically create the court size and positions this one automatically based on wherever our playfield grid is going to be. When I now hold on control, I can snap to any other great over here as well as I can go inside the scale in scale. The playfield down at as you can see, one by one represents a 10 by 10 grid sized plane. You can counties up or you can see this on this lines over here. So whenever I put in something like 0.4, you can see that the X X is now is four squares in its size. Keep that in mind. We gonna need this later. I'm gonna do the same on the Zad access. I don't touch Why? Because it doesn't has any height. But you can also see on planes. The backside is transparent, absolutely helpful for our game in the future. Since the camera cannot looks through it or actually can look through it. And the player will not be distracted by anything. When I want to do is we hold on control and snap that or snap. Drag this to this field a point over here. Once again, keep in mind on a play. Field starts over there. If you want to keep track of where the Playfield position is, you can always make use off these Aikins over here on the Little year Cube. In that case, I gotta give it something like a bubble or just a sphere to indicate. Okay, this is our start field. So this is going to be our bottom plane. So I got on rename this one bottom also what I want to create. It's a material which is sitting later on on bottom. But before we do that, we just duplicate this one and create for more on your form or walls for our axle playfield . So what it can do is your select bottom and press control de on Mac should be Command E. And then we just duplicate this automatically all down control again and snap it until it has 90 degrees snapped. Also, we can hit W to move it back once, for example, and position it wherever we like him. Please. If you never ever worked with snap settings before, you can always go here, Toe added Snap settings. And in here you can put in any values to like, for example, by snapped rotation. You always do 15 degrees in wherever the access issue are doing. My scale is set to 0.1 move X Y, and that is through a 0.5, meaning I always move. Snapped half a unit in unity. With that, if you don't know where you are, whenever you have freely do done that, you can also say I want to snap all axes and they will go to the next or closest access to that. Then, once again, you hold on control and he can snap back wherever you had that Good. Now we need to make sure that we name them correctly so we don't distract ourselves or get confused. As you can see, the blues, an axis is usually the forward access. So I would take this Is that access and make this as an indicator for our north direction. So I gonna name this one the in plane or just in for Norse. Of course. When we now duplicate that, bring this to the other side, rotate by 1 80 degrees and then we'll rename this 12 s. This represents the 1001 like the cells plane. As you can see, wherever we're looking from or to this, planes are always looks Rue planes. I got a duplicate s. Now hold on control. Rotate 90 degrees left or right, Does matter and move it to this position Over here. So this is going to be our east plane. Or in this case, west. So was a W sends Norcia. Then comes east, south and west. So now we have a west plane. Of course, we also need an east point. I'm gonna control de duplicate, rotate by 1 80 degrees and rename this one to E for east. You could also type out whatever you like and please. Now you can see whenever we looks rule from ever ankle we are looking from We only see through the plains from its back sides and we never see any other ones which would to distract us or the player to not see whatever they want or do not want to see. That's pretty decent. And basically, this is the base set up for a game field. Now, we just can put in any material onto these planes, but we need to handle all of that three types differently. Why three? The bottom will have a different asshole material in a tiled in its size as well as it will have. The Western East will be different as well as North and South will be different when it comes to sizing. We're gonna talk about that, but we're gonna take care of the material in the next video. 5. #5 Playfield Material: Welcome back to the course in this part. We're going to take care off the material on all Austria planes. Before we do that, I want to set up some things inside my project window. First off, I select or highlight assets. Right click. I want to create a new folder, Cold textures, because we're going to import, like, at least three of them later on into this you can direct. They do that by opening the tax just folder. Unzip the zip file course material and drag in all the three PNG files. If you like to, you can also only take the grit material. This is totally up to you. At this point, I'm gonna drank all three in so we can see that that we have done this so far. We also need is a material solder where all our materials are going to land in later on the material for all the cubes or blocks, as well as the material for our grid or for our playfield over here. So I created new folder. Call this materials, make sure you create for everything an own folder. Otherwise, you later on half a big mess in your set up or in your seat. Now what you want to do is you want to create a new material and we can name this one bottom grid. This is important. We need to split this into three pieces or three materials to duplicate the material we can later on goal and his control D as we also did inside the playing field, over here or inside the scene view Well, we know want to do is we want to Before we duplicate the bottom grid. We want to set it up so that it understands our texture and how we want to see and handle that for a stuff we goto standard cider in two K 19 off unity. Currently, I'm working at two in two K 18 point to something You want to make sure that you take out where the seders are. It's looking here a bit different. So no worries about that. You can always do that and you will find what I'm talking about. If you don't find it, make use off the search because took a 90 now has a search inside its materials. Yes, set up over here So once again or we looking for is a material which is basically unlit, but also it is only visible, I guess over here and the legacy standard diffuse Shader. And since this is a transparent seder, it will take out some colors off our grid. And also we want to make sure that we only have a diffuse general over here. Diffuse means just a plain color with nothing else, but that also has a concede has a base, our GP, in which we can now bring our grid material. As you can see, whenever we rotated over here, it's barely seen in the bottom, right? We can also bring this up a bit. You can see it is already transparent. When we know, Take this bottom group material and drag this directory onto our bottom field. You can see we see one grid like one outline off this grid from the bottom. We don't see anything because off the planes, as I already explained before, we now can this, for example, whenever we have a four by four in its size, we can do a tiling or four by four. This will give us as you can see, a grid off four by four based on this particular texture, type or material type. Since we don't want to receive shadows and stuff like that, we can always go to the bottom over here to the bottom plane and say, Receive shadows off and cast shadows office. Well, same for the other ones we can already do that just sent, receive shadows off and cost shadows off, since once again we don't need them. We still see them over here or it's not a settle. It's more like a ah cut off or fall off, which is coming from the camera. But we don't need to worry about that in the future. Since we have the bottom group material done already, we need to create one for North and South as well as for Western East. So we just doublet Kate that and we hit F two to rename this material inside our project so we can say and minus s or something similar grit. So this is going to be the North 1000 grid material. You can also once again doubling Kate that, and rename this by F two, which is going to be our W minus e grit material. So now we select n and s and drag our material onto those. If n does not receive it, then you just drag it directly onto it as single same here, this is the W. This is the one we want to make sure that we take the W E material onto this two walls over there. And now we have basically everything set up for the materials. If you like to. You can also compare all of that settings inside the game view to simply fire a process. I gonna choose my senior over here. Bring my playfield kind off, insert the center, Select the main camera game Object line vis view. What you will see is that the camera will catch the same information we're going to see now here in the scene, view inside the game view. Also, if you like Teoh, you can already get rid off the skybox and choose solid color and maybe make a black background for visual purposes. If you now go maximize on play and prosper play. You should see a complete grit over here. 6. #6 Coding Playfield Grid 1: welcome back to the course in this part. We want to take care off the grid itself. So we want to start to create our first code, which is taking care of the size of the Playfield based on the settings we are going to give to that. So first off we go toe or medium assets holder and creating new folder called Scripts, and they're almost crypts are going to be inside open this one, rightly creating you see shop spread and call this whatever you like. Maybe Playfield Grid is not a good name because unity has a new function, which is called grit already. So make sure you name it playfield or the grid or whatever, but not grit alone, because there will be problems in newer versions off unity. Select your playfield game object and drag the Playfield onto it. So all our settings we are going to make about the Playfield will lend inside the playfield grid. Double click. There's run gray name over here To open the script, Amona developed visual studio over whatever i d you are using. I'm using some some part off a new of moral developed version, so I gonna have to open the playfield. See Ship script over here. I gotta zoom it. Slide bid so it can sti c stuff better and hopefully good enough. What? We wanna do it off. Here is the very first thing we need to declare All our planes were going to have as game objects, and we need to drag them inside, overplay feud so it can take care of that. We're gonna make use off the keyword public. So it is public inside the inspector. We can excesses without any problems. So in that case, it is going to be the type of game object. Are we gonna name this one? The 1st 1 on bottom plane. So this is where our bottom plane needs to be dragged in. We also need one for one north, south, east and west plane. What we can do is we can simply find this progress by putting all of that stuff and one line so we can say. And comma s comma w comma e semicolon can also put everything behind bottom plane. So we only have one indicator for that stuff. For now, I get rid off starting update. We're gonna take care of these a bit later on the most important friends and we're going to talk about is it coming in a second? We also want to define already is our grits, highs and whatever our group is going to be about for a self, we need three very Abel's. We need an X y and that coordinate for the size itself. We can do it in three different ways. We can do create three single inter just, Or we can also put all this information in a vector. The problem was, the rector is it is never rounded. So we gonna make use often indigent. So we gonna name this inter jizz grit a size X I gonna do the s and the X bigger so we can see stuff better. And since I'm lazy, just copy the name. So I selected and pasted over here and rename it to why commas add. So we're gonna be a bit more efficient in creating coat whenever we could duplicate stuff We also do is we create our grid already, which is once again a three dimensional right for X y and zap coordinate. So our rays of type transform. Since we want to store, transform information like positions. And then the rays always declared with square brackets, this would be a one dimensional ray was a comma in between. It would be a two dimensional array with another calmer. It's going to be a three dimensional ray. We can give it a name, for example, the grit. We do not do anything about the grid at the moment. We just want to make sure that we have that already. And don't confuse, get confused later on. Now what? We want to do it. Since every single set up so far, we're gonna create a new function. This is, ah, function of type point. Since it doesn't return anything. And now I mean, you need to be careful. It is called on drone gizmos. This is a unity provided function which you need to type 100% correct. Like big go big depict G. Otherwise it's not working. Make sure you have that we want to do is we want to resize now or bottom plane based on the import in the axe and those that size. How do we do this? Well, andro gizmos runs the world time in Editor time. So what we can do is whenever we are in Unity editor and change some values, we can update whatever we see over there, Andro gizmos should not be laid on active in the built, so we're gonna take care of that later on. So we want to do is at first. Since it is currently running the wool time in editor time, you want to make sure that if the bottom panel is not equal to know or bottom plane is not equal to know means we have dragged anything inside already inside the bottom plane slot. Then we want to resize this bottom plane once again, based on the input for stuff, we want to resize it. I'm gonna make a comment over here resize Fordham plane when we no need to do is we create a new vector three, which is going to take the scaling for us all will take care of the scaling for us. I just name it scaler, and we set this one equal to be a new of Vector three. And in open, close parentheses, we now can do whatever we want to resize our vector to. In that case, we can take our grid size X, and we want to do with grid size acts. Since a plane is always 10 in its size and do your 100.1 would be one unit we're gonna need to divide that by 10 was the scaling possibility. Now, since we have actually divided that we might get in a row because grid size X is off type into GIA and an introduction, which is maybe only a size off 10 or five, and we divide five by 10. If it is not a float, it probably does not give us a correct answer or number. So what we're gonna do is we do actually typecast this interview, uh, into a float. So in parentheses, in front of that, we're gonna set the group size X divided by 10 into afloat instead of an integer. The vector can handle that. So no worries about it. When I want to do is we want Toe said, Why and why is the height? We don't want to do anything with that. So is keep it to be set toe one, and now we're going to do the same for the Zad value over years. I copy this complete part and bring this in the last area. But we need to rename this one to be grit size that divided by 10 and we're gonna enter line with semi column Now we just scale so actually stored information based on input, acts and input that into the scale of actor to re scale now are bottom plane. We're gonna need to talk to it so it can say bottom plane don't. And now you take the local scale which sits in its transform information. So bottom Blaine not transform. Don't Local scale is equal to whatever scaler is going to tell us, but that is not going to be enough. We also need to reposition the bottom plane because whenever it's becoming is bigger and the pivot point of the plane is in the center off the plane. We need to reposition it based on the size related to our playfield game object. How do we do this? Actually, we can once again talk to bottom plane. Now we say, don't transform. The position is equal to and now we need to recalculate the complete person reposition based on the size. So we say new vector SSRIs. So once again, we put in a new vector three open close parentheses and now we take transcendent position dot exe, which is going to be the position off our playfield are a small game object which is holding this information over here. So this is once again the current game object we are sitting on. Now we need to add the size off grid size X, and we need to divide this by two. And we're probably gonna have another problem over here Since when we have a five. Ah, this case. So when grit sizes five on, we divide that by two we only get a two or three. So we probably want to take this and convert us into a float s Well, this is now becoming a rez along vector calculation over here, so we can actually put all the the upcoming stuff into the next line if we like to. So we just hit comma or enter in this case, bring this off a year. Take the apprentice e with you and now we can type for the transform Don't position, don't why? And the why is not changing in its height, we're going to stay at the Y position. And now we also need to do the same for those that value. So transform Don't position. Don't in this case, the that position off our current game object. And now we add grid size. Is that to it? So plus grid size that divide this by two. And then, of course, we typecast this one into a float. Once again, my screen is a bit too small. I don't like to scroll around. So I bring this over here so you can actually read. This one will hopefully better. And what we finally do is, of course, we end the line was a semicolon. So once again, we gonna reposition the plane, which it has. It's a year base. It's Vector is going to be in the center, off the plane. We're gonna talk about this in just a second. So we add the four grid size divided by two. So criticize X divided by two. Is the half off the plane size or yeah, actually, the half of the plain size in that case, and then we'll bring this or add this to our current value. So our current information over here why I will not be touched because it's the height off . The plane will stay wherever it is. Where about what Playfield is, So it will always follow up. And the sad value once again is related to the grid size that divided by two converted to the float. So we also get comma numbers over there. So whenever we have a five who have zero comma five added to this that value Let's test this one out. We go to our unity window. Don't forget to save the script, always safe whenever you have done any changes and as soon as we put in the bottom plane over here we can see something which means it re size is 2000 As you can see, the bottom plane is now completely school scaled down to 000 you consider. Except that why is going to stay one now? When we want to do is imply field we want Ghana sent. I want great size to before and why is actually not important. But that value is going to be four. And now you can see it once again fits inside over here. So depending now on the grid size. We can actually scale this 1 to 12. So on bottom, plane has now a scale off 1.2. Pretty good. So that's what we want it. Now we just need to take care off the scale of the material. I'm gonna bring this one back to four by four. So it's still matches, and then the next part, we're gonna scale the material off the bottom plane. Don't forget to save your scene and please. Safe often whenever you do changes, police always safe. 7. #7 Coding Playfield Grid 2: Welcome back to the course in this part. We want to make sure that the material on the bottom plane is going to can recalculate its tiling automatically whenever we are re sizing X exact coordinates. How do we do this? We're gonna open up. I want Playfield script and then I want drawn. Drug is most Langton. We need to re scale our material or ask they we need toe re tile. This one I'm gonna make another command material. So how do we do this? As a way of course. We need to talk to bottom plane and get its component of type measure Endara and take care of that. So bottom plane don't. Now we want to get its component off type mess renderers, which contains all materials and stuff like that. When we say don't and then here we're gonna take this shared material. Usually we should also be able to take the normal material. And then we say, don't main texture scale this one and we want to re scale this texture to be whatever and then we created new vector to our settings are in grid size X Ingrid size Zet. So grit size X comma grid size Zad looks good. Don't forget to save and let's go back to unity. Let the compiler run. You always see when the compilers running in the bottom right corner. And now let's, for example, take a 10 by 10 grid. What it can see is the bottom plane automatically Recalculates how big the grid or tiling off the material has to be. And now we can also do the same stuff for the other ones over here. Once again, this is important. So that's how we can night on simply create a complete visualized grid without touching it laid on anymore. In the next part, we just copy and paste stuff around for the North, South, West and East planes. 8. #8 Coding Playfield Grid 3: welcome back to the course in this part. We gonna take care off the Northeast 1000 West ports. Meaning we want to scare them up and down on the Y axis based on the height off our playfield as well as reposition them based on whether they have to be related to overplay, feel point over there. That's open the script for our playfield. And let's go inside our own drugs. Most function again. As you can see, basically, what we need to do is we need to do the same for all the other ones. But we need to change. Some year points over there we need to do is at first we gonna copy all of that stuff for the bottom one and bring this over here. In that case, I gonna start with the North's on one. So the scaling is basically the same. We're gonna have an extent of that plane brought. This plane is actually not scaling in the Zad value brought. This is scaling Onley high into the Why will you? So we're gonna need to change this one, Toby. Grid sized. Why? Because it is going to be the height once again. And The rest is based on the X access off our input over here. Since once again the plane is sitting when this is the X axis, you can always see that over here is only re sizing this side like from left to right on its X access. And it is resigning this size based on the why Williams of the height, as you can see, is the why off the y value over there. That's why we need to change this one here to be based on the why and not on the set grit size next one, as we want to re scale it based on the input. So we say and don't transcended local scale is equal to scaler. Now we need to reposition that and this is going to be a bit more Yeah, acid tricky over there because we need to make sure it always adds to the full size on X and the full size. 0.5 size off the X X is black. Its position based on the transform and its full size in Zad and access basically and not divided by two. So how do we do this? We need to do the same. Over here, we add to the X X is its half off its size once again because the pivot point is in the center off the actual plane, we're going to resize the why value is going to be care re calculated based on half off the grits. Why value basically so in that case would take transformed our position. Don't why? Plus, and now we're gonna add half off the grid size. So I going on typecast this into the float, Say grit size. Why on divide that by two. And the sad value, as I explained before, is going to be just the complete. That value plus the complete grid size of years. Are we gonna be able to get read off this piece over here? So we only have transformed positions that plus critized that and that's everything we need to change for this and the measure. Hendra is basically based on grid size, axe and grit size. Why? Once again, we are rendering acts and why coordinate and not X and that as we did in the bottom one off course, we need to make sure that we are not repositioning the bottom plane. We want to make sure that we reposition n like our north plane. Same for the tiling. Over here. We're gonna take the sad material off the tile off the main texture from n as its component . Don't forget to save and let's go Bank to unity and wants to compile is done running. We should see everything updated correctly. And since we haven't set any why, well, you in its height, we are able to do so and we can fulfill the tiling over here again whenever we go higher. Now, what is eight, for example? You can see the tiling works as it has to, and the opposite one which is going to be this one over there also tiles by eight because off the setting over there. So for the 1000 area, we can basically do the same as we did with the northern one. So let's go back to unity. And basically what we can do is we can just take, ever sing from the northern one and to bring the same stuff into the cells on one. So we copy the complete if statement over here and bring this over there. So what we know want to do is we want to check for s So if s is not equal to zero, we're gonna rename over here Toby s as well. Same here for repositioning and same here for material. Basically, this material is shared by n So usually we don't even need to re tile this material because it's basically doing the same as we do in the northern one. I command this one out to show you don't forget to let the compiler run, and it should automatically resize and reposition itself whenever it is set inside of a play field. So we drag us into it, wait a second, but we don't see anything because we need to change the position off s a back to over here so we don't bring it into the full size off the sad value. We just leave it at that, that value wherever it iss. So we're gonna get rid of this last part over there like that. Don't forget to safe. Go back to unity. Let the compiler run and you see it automatically updates itself when we know once again increase with the Y value over here. The tiling off the shared material on the North and the 1000 plane are going to be 100% correct. So I'm gonna bring this one down to four again or probably something like six. So we see the difference later on on the West and on the East plane as well. But that's what we're going to take care off in the next video. 9. #9 Coding Playfield Grid 4: Welcome back to the course in this part. We gonna take care of the East and the West plane in almost scripts, and we can automatically resize and reposition these planes as well. To do so, we go in to our Andhra gizmos function in our Playfield script, and we can't be the complete part off end over here and bring this under s first off. We rename this one over a year to be, let's say E or w basically doesn't matter which one you are going to prefer first. So let's take the east Someone I got a taint all of these 1st 2 East since East is going to be related on accidents And why, in its main texture scale, we don't need to change anything over here. But what we need to do is we need to reposition this one different the x value so from left to right and said that this eastern one, we do not divide it by that we need to do this like full grit size X. So we get rid off the float as well as so the divided by. So we repositioned this one on the X Plus two full excrete size. But why will you stays the same? And his add value is going to be the half off the size. Or like the center off that in that case, we need to say grit size that divided by two. And we're gonna typecast this one into a float here as well. Don't forget to save on. Let's check back to unity. If I know increases that value, you can see this one is no changing its that value. But what you also will see us, that this one still is based on the X axis. So this is what we need to change over here from grid size X two grid size that on the X axis off the plane we're going to see the change into us a second whenever the compiler is done. Now we can't say this works, so it fits over here. It just does not fit the scale in its shared material component because the X access or the X value is based on group size zed and grit size. Why, that's safe. And let the compiler run once again. And there we have it. So it fits 1% in the size as well. And the final part is not going to be the other way. The other word Thea other plane on the other side, In that case, the W one. As you can see, the shared material already tiles it correctly. We just need to reposition and resize the complete plane over here. So in that case, we're gonna take complete E copy that bring this down below, rename it first of a here to B W W W W. We don't actually need to re tile it because it's done already. Boy e over here and it's coming next to it. Or after that. So it automated does that. And also it's a shared material or actually the same material boats are going to share, and we need to reposition this one. So since this is a W, it's going to be left or basically on position X wherever we are already without Playfield so we can get rid off that part and don't forget to save. And this that and the Y value should stay the same in its position as well as the scaler. Should be working now. Correct. That's tests it out at the compiler run. Whenever the compiler is done running and we're gonna add W 21 will play field. It should order medically, Reese Ice. Now we can build any size off the game without any problems into any direction and any size we want tohave our game into, I believe we're going to start with a five by eight by five. So five and X five and set and eight and why? And everything else about the playing field is now just a doing navigations. So we're gonna start off with probably camera navigation as well as start to create or first blocks in the next coming videos. 10. #10 The Camera 1: Welcome back to the course in this part. I want to create some camera input where our player is able to navigate around this Ah, national piece of a years old playfield. So we kind of think about or need to think about how we want to do this. I want to do some kind of a mose touch input. Meaning Whenever we're touching on a device, for example, we're gonna have the same functionality as whenever we're doing or were where we were using a mouse. And to do so, we need to have a point where we want to rotate around. Also, we need to have another point which is doing its several different rotation. Let me explain that. Let's assume this is going to be our rotation point. Well, we need to do is we need to rotate this point into one or the other axis. For example, if we would go and bring this like in the so called like only rotating over the Y value. So the y axis sister up value, which were rotating around then we cannot make it so that we're gonna bring this also or rotated also over the Zad value why is that so? Because we would have us rather strange behavior where because we cannot bring this anxious back to where it has been before. And we would just rotate, maybe like this over the Why Williams. So we would rotate this way. So to avoid that, we're gonna take two different targets which are doing different things, like different calculations in ankles for a self go to us groups all the and creating new spread c sharp and name it, maybe camera control or cam control. You can also shorten this by Cam Ctrl. Well, all of that totally up to you and opened this one in mono developed visual studio or whatever i d you are using once it's open we wanna do is several things over here. First, we need to define the two targets I was talking about before. These are going to be of type transform. So we're going to create a tent transform target. So this is going to be the target for our Y rotation. And then we're gonna have another one which is going to be represented for the accents. That rotation. So how do we do this at first? Well, we gonna do the second target over here on the second transform, which is going to be our row. I gonna name it Rot target. So the rotation Tory, once again, the target is also doing rotation, but we need to define them differently. Then we What we need to know is a vector where we have touched before or the last frame. So I'm gonna name this one. Something like last position or last touched position. You can name it, whatever you want. The next one is a sensibility or a sensitivity. And once again, totally up to you. How we named this send is the Tiv ity. This is going to be of type float because this declares how harsh our act with the mouse or finger touch is going to be. I gotta set this one to resolute number something like 3.25 or something similar. If the higher you go, the faster it accent, probably it becomes a rez, a shaky. Whenever we are actually doing a direct movement off the camera control, the start message is going to be one we gonna rename To be awake was a big A. This is important So the first thing we want to do is we want to find our rotation target as well as our usual or normal target. So we say rotation tire yet is going to be equal to our transform dot parent. Why? I said so because our camera will be parented to the rotation target and the rotation target will be parented to the target. We gonna do the set up in just a moment. Whenever we're done with this stuff over here, and I'm gonna explain why the next one is going to be We need to find the target. And once again, since we know that the target is going to be the parent object off our rotation target or rots target, we gonna say target is equal to rotation target that transformed out parent so rotation target don't transform, Don't parent. Right. And that's everything we want to do in the wake. So we automate that stuff and we don't have to touch anything, direct any stuff into whatever. We only do this an update. We want to make sure that our camera, which where this camera control was sitting on, is always looking toe a target. So when we do is we say transform dot Look at target. We could also use the rotation target because Beau's will sit on the same spot. So I gonna make use of target because this is the outer parent. So the last part, actually over here and not the rotation target. Probably a better choice. We don't want to do us whenever we're doing in mouse inputs like whenever we click on the left mouse button, we want to store our current clicked most position into the last position over here. How would we do this? We say, if input don't get mouse button down so we click only ones. We want to make sure that we take zero as an argument. This is going to be the left most button and can be also make use off or make used off in touch screens. Most of the time in enjoyed it works. I'm not quite sure about IOS. That might be a bit different. We don't want to do is we want to save our clicked position into the vector three last positions on exposition is equal to input that mouse position. So whenever we have collect, we're gonna store that in last position and finally an update. We want to do our orbiting around these points, so I'm going to create a new function called off type Void says you don't return anything and we call this orbit and an update. After this input, we want to call orbit open close parentheses. Close the line. Was this in my corner? So now, in orbit, all off our imports are going to happen for herself. We want to make sure that mean why we held or hold down the left mouse button. We only then want to do input. So if input dot get mouse button open, close Francis's input zero. So once again, we hold down now the left key. So in here we just click once, and here we hold it down. We want to store information in the vector. So first off lectures. Three. I gonna call this Delta, and this is going to be equal to input dot And now we take once again the current most position. And we need gate that by our last position, this is the delta between two points like this is a point of vector between two points between our current man's position and the last so in this case, the colic position. The higher that value, the higher the Delta is. So we have no a distance between two points, and based on that, we can calculate ankles. First off, we're gonna create a new float, which is going to be angle. Why? So why angle and we sent Is this bone want to be equal to negative delta dot Why? And multiply that by sensitivity. We're going to do the same for the X value will copy that. Just rename the ankle to be an ex ankle. Gonna take Delta X, but not negative, but positive. And multiply that by density. Now we're gonna take care of the X excess, so I'm gonna explain it in a second again. So the XX is is the one which is doing the up and down movement basically around the target . The Y axis is going to do a rotation left and right, unlimited aid on once again. We also have and why access the Y axis is probably a bit easier. So maybe we're going to start with that. So what? We want to rotate when we are rotating over the Y axis is our outer target. So we can say, wrote a target, don't rotate around. And now we want to rotate around a spot and this is going to be a vector of position. Somewhere in this case, we're gonna take the target position. Now we want to declare what is their axle access? We want to rotate around, is going to be vectors reader up. So our up vector in this case, the Y axis. And when we want to take s and input like, what is the angle? In this case, it's the X ankle. So angle X over here. Ever get the end the line with us in my colon? Whenever we have done with that, we want to reset or sad last position to be equal to, Of course, our input dot most positions. Are we updated? Whenever we keep on dragging, we're gonna have to recalculate Delta over here. Let's test this out. So for and set up and let me explain about the axes first let the compiler run and whenever we had done was that we're gonna take our main camera. It's currently over here. Doesn't really matter. Weight is we're gonna set this up in the SEC. I got to create a new empty game, object first and rename this one to be our target. So we don't get confused. I'm gonna make a point. Once again of a year, Maybe another one was a green and I got a position, This one somewhere in the playfield, like over a year in the center. Later, we can automate where this is going to start. At first off, I resented to 0 to 0 and I snapped. Drag this one over here into our center. Since we currently have a five by five field on may be dragon also up, like over here, since it will fit somewhere in between our eight in its height. Once again, if you're happy. Was that or even not? Just make sure that you put it anywhere. Now I got a duplicate target or actually create a new empty inside target which is going to be our rotation target. Rod's target and know what I want to do is I want to take my main camera and bring this as a child off rotation target. So this is our initial set up to make sure we don't have any strange behavior over here. We gonna reset the position and the rotation and all the other stuff off the main camera and we drag it away a bit. You can always see this in the game. You know, we can take the target and rotated a bit if we like to the outer one. Since Dad represents the correct info, I'm gonna bring that off the camera to maybe minus 12. So we Seymour off the game field, we can now navigate around it, make sure that on main camera, you drag camera control script. Don't forget to save your scene and let's press play and see what's going on. We now should be able to rotate just with our mouths of a hell, like doing left and right mouse input. We should be able to drag our playfield around and get the feel off three D Currently, as you can see, it only takes the X delta values. But when we go up and down, nothing happens. This is because we haven't implemented this one at the moment. 11. #11 The Camera 2: welcome back to the course in this part. We going to do the final touches on our humane camera input, Meaning we want to make sure that we also able to rotate about the rotation target something like this one. So we can looking from bottom to top and from top to bottom, we need to take care of us. And there we gonna clamp for the input at a specific angle. That's open as a script where we have created the orbit inside, like in our camera control. Now we need to update everything about the X axis. So the rotation I just showed you was an ex rotation. To do that, we're gonna need to calculate some ankles beforehand. First off, we're gonna store our current angle into an vector straight. So vectors three angles is going to be equal to whatever the current rotation target Don't transform. Don't Ula ankles is going to be. You gonna store this and here because we cannot directly to changes to am the rotation, your ankles. So we do the recalculation update ankles and laid on. We're gonna update rotation target. You will angles by the input we have re calculated first off, we're gonna take ankles dot exe and we need to add plus equal angle. Why? So we're gonna do and take the ankle? Why? Over here? And add this into this vector we also want to do is we want to clamp this input. I'm gonna show you why. And whenever we had done was clamping. We're gonna do the clamping in just a second. We want a set rotation tired. Get a door to transform. Don't you ankles to be eagle toe ankles. So, as you can see, we only manipulate the ankle X in our rotation over there. The rest is done by the target on its y value. So we cannot over do it. But before we gonna do anything else, we, of course, let the compiler run. See there if any arose and test this out. So, for there are some problems we will encounter when we keep it as it iss First off, I can now go up and down pretty decent. But what if I go too high? What you can see? The screen starts to shake and does not really know where the heck am I? Same on the bottom. It still works as I can see, but it's not really nice tow. Avoid that. We gonna clamp ankle X between two values. But we cannot make use off message thought, Clem, because the problem is that we are not able to clamp negative numbers correctly. In that case, we created little help of function for doing the clamp for us. So I gonna name it. It's not of time. Void. This need to be off type float because we will return afloat in the end. And gonna name is one clamp angle open, close parentheses. And now we need to put in some informations for herself. We need to have a flute which is representing by our angle. Then we're gonna need to have another float from where we want to clamp to. It's going to be another float to to where we want to clamp. So we need all of these calculation information over there. In the end, we want to return mess F Dodds Men, open girls, Prentice's ankle comma two. But before we can return that, of course, we need to do some calculations with our ankle for a self. We want to make sure that if ankle is smaller than zero. We want to set angle to be equal 360 plus. Whatever the Inglis, we need to do that. Otherwise, unity will have some strange. Your problems was that since it cannot work in negative numbers with local, you lie or you'll ankles in that case. So we're gonna keep that whenever it's smaller than that. We just said it to 3 60 then add the angle to it. We can do or have to do the same with 180 degrees. In that case, we need Teoh return something over here already. In that case, we can say if ankle is bigger than 180 f so one on 80 degrees from doctor board from bottom to top. Then we want to make sure we return mess f dot max and in that case we're going to return the ankle and then we put in 3 60 plus the from value and of course and the line was a semi colon. So once again, whenever the ankle smaller than that, we answer 60 to it and to this, or actually set the ankle to be equal to 3 16 at the ankle, so we don't have any negative values. But we can negate 3 60 whenever we have 180 or were higher than 180 in case off degrees. Then we send the ankle and to take 3 60 add basically the from value into this. Once again and year, Max is going to return as you can see the largest off two values. So the largest between the ankle or from the ankle and whatever the input is plus 3 60 same hand, that's going to take the smallest value between angle and to. So when that does not fire, that will fire. Now we just need to call the function and take this and manipulate ankles or, in this case, ankles X. So we say ankles dot exe IHS Equal to now we call ca lamp angle. We put in whatever ankles, adored access. Then we can say comma, and now we can say between which our values we want to claim. I want to clamp between miners that say, 90 or let's say, minus 85 do not go over 90 better and eso 85 or negative 85 85. So in negative and a positive number over here. Don't forget the interline was a semi colon. Whenever we do this, we will never exceed the point in the bottom or even in the top. And we do not have any strange sake behavior. Don't forget to save. Let's go back to unity, letting compiler run, press play and tests out. I want current camera input. I try to do it. As you can see, I'm clamped already, and it can always see what the ankle is off the camera. And, as you can see in X rotation or in this case, their rotation target is claimed to be 85 degrees plus minus a small bit so it cannot exceed Overdo it. Same for the other way. We can go to the bottom rotation target. There's no minus 85 degrees in the X value, and nothing else needs to be changed over there. So now we have a fully functional rotate left, right, right to left up to down and don't toe pretty good. Now we can go and implement the work or the first teachers blocks and create the functionality off the game. Even more 12. #12 Creating The Blocks: Welcome back to the course in this part. We want to create our first blocks. I'm gonna explain how this is going toe work and what we need to take care off. First off, that's great. An empty game object. We always need to have an empty game object because this is our rotation pivot point as well as movement. Pivot point off our objects, like off our blocks we first want to do is we want to reset it. So it's sitting at 000 wherever while purple wellness Make sure you don't retreat it as I did. Now what we can do is we can, based on the position off that we can create our first block. Let's start with our tea piece. So I gonna rename this one to Teepees or t block. Once again, naming convention is king, and it is important that you know what you're doing and what you're talking about. So when we have tea block or whatever you named it selected we create a new three D object cube. There's Cube will be centered on this point, or on this piece, we will make sure that we scale this one down and explain that to 0.9 at the very first. Why I am Because we can see this one later on easier whenever it is sitting inside the play field. Also, the player which is going to play our game want to see even more on that. I got a select the Cube. No and duplicated, we can once again create these. Don't forget to sold and snap that to the next position Over here, to the next position over here And over here. So we get the T piece just like vice words alike rotated around. So what you can see is our block itself has its pivot. Now in the center off the centre block that means around this block or this point, we will later on brought aid in all directions. Like this way, this way. And also this is where we're gonna start to move things around, like left and right up, down. Okay, so now we know how this is going to set up. Or how we set up our points are want blocks. Totally. We No wonder this later on inside the grid, you can see we can already try to position this over here inside a work red. What you can see now is that the block itself since on a comma value, that means we later on need to reposition our grid directly. Or Playfield. So we always get, um, vastly coric values correct. In this case, like full interview numbers. So we later on need to do is we need to take our playfield position and reduce it by half into X. Why? And that coordinates to have even numbers. So as you can see my t block right now, when I would send to this one over here and we would start with our playfield over there, we would have an intersection. So we would need to go one in this way. One in this way and one in this way. So otherwise it will not fit like our stone. Ah, position would not fit. So you can see the playing field later on is going to send. I was going to be somewhere there might like, for example, in minus 0.5 or plus 0.5 in all three axes once again. For the moment, it doesn't matter what you know also can does. It can create some materials for all these blocks. We can't resin Simply do this by, for example, right click creating new material and no more material smolder. I like your name in the red You can name a blue, green, yellow whatever your please And like I can duplicate even that one renamed by F to rename it to yellow Duplicated once again rename F to name it Green once again controlled the rename on We can also name it Blue You can take any colors or any names or anything whatever you please and like and rename them make use of them So I'm gonna take blue and make it anyhow, Blue I'm gonna take green and make it anyhow Green er's Then I'm gonna have read already and gonna make yellow a bit more like orangish. Okay, maybe also Or maybe I go a bit more more yellowish. I don't know something like that. Maybe you can create as much as you like. You can later on also make use of white and gray scale ones. Depending on how many pieces we have, the more colors relate on. Probably need now. I gonna duplicate the T block before I do anything and bring this to write. Don't forget, you can always use snap to bring stuff clean to one side or the other. I want to take the ones from our actual Que Pierre and oh, I maybe gonna duplicate this once again and make it purple. So purple is one color I like to see on this one. You don't need Teoh. You can so maybe some dark age purple And now I to select all these cubes and take purple and bring this onto these cubes. You know, you can direct them like this, but you can also direct them in the Inspector And all of these will tint purple. So far, so good. This next one is now going to be maybe our eyepiece. So I going to rename this one, too? I belong. It also has a four blocks inside. I want to make sure that my pivot point is going to be somewhere at the second point, I gonna going create us from top to bottom. So I take this cube and bring this Don't over here and like that. And this one can now be in top or in bottom. I want to make sure that the center point, like the I block pivot point is going to be in one of the centerpieces. So maybe I gotta take it like that. What does it mean is now when we rotate, we always rotate around this or this piece. So we don't have laid on any strange Indus actions. We cannot, as we contend it to whatever we like. But we can also, before we do that duplicate this again doesn't really matter. Selected control D and the dragon to the side for the next piece we're going to create in a moment. So and we can I take these by holding down, shift or just go into the hierarchy and make this one? I don't know. Maybe greenish, you can once again take the color and drag it directly in the inspector. So all of the the year blocks are going to have the same set up. No forces that peace once again. Remember where this private point is and where you want to rotate those that piece around. Usually it's going to be this piece, meaning this one going to be here in this one is going to be here, so there's that peace now will rotate around there's block like so if you don't like this one, you can also do This basically does matter because you are laid on also able to make it in s or is that block up to you? So I gonna name this one? Maybe is that or s block once again? Doesn't really matter because we just want to make sure that we only have that whatever we need to I gonna select them all and make everything blue Or maybe yellow. Something like that. So next one is we need the Opie's. So the OPIS is the one which has a four by four or two by two actually connected so that it has more child objects. Once again, I doubly gate this one. Bring this all over the place. Over here, I rename this one to be my OPIs or block, and you have several possibilities to create your own ones. And you can do any strange behavior in any strange shapes you like in please. The old block is basically you can pick any corner you want to rotate around because usually we don't even do any rotation on that so you can do the A block like this like it has no death or death, or you can take all these cubes, duplicate them inside and bring them behind. So you have, like, a bigger one since three on three D space, and it will fit inside our great no problem with that at all. Also, you might want to go and give it any color. Maybe something like, Well, what don't we have? Well, maybe the blue one. I got a W gained yellow color over here. And just in case I want to have a white color. When am I renamed This two White. And I go over there and a pick for white, for example. Whenever you gonna have one piece which has to be white, then you have the color as a material lying around over here two blocks which did not change their color. Toby blow. So I gonna gonna pick them and give them video here as well. Make sure you are working as accurate s you can. So and from now on, you have a lot of other possibilities to build. You can. We can also do an L. As I see you're gonna take this this long piece over here? The eyepiece and rename this want to be l l'd look gonna get rid off the number and I'm gonna do it a bit different to the LP's. Probably I want to have the rotation point some way here. Meaning Let me first bring it away bit so we can see stuff better. Meaning I gonna take all this pieces from the eyepiece. Bring them to the right like this, I might take. That's pretty quickly. Check this out. Let's take them or Oh, no, it's fine. I'm gonna take the upper one and bring the upper one down. So what I do have now is that the rotation point is here in the center, so meaning were rotating around the center. If you don't like it, you can always take anything else. You can also rotate around this area over here if you like, Teoh. So in that case, you just bring over all the pieces like this. And in that case, you would rotate like this. Everything works up to you. Totally. I gonna go with Dad way. So the pivot point or the rotation point is going to be here inside this little corner or so I can give it another color. We don't have red at the moment, so I'm gonna take all of these parts anted this one, right? If you want to have any more shapes, like maybe only two of these or just half. And, oh, like only the front over here or any other fancy shapes. Absolutely. Go for it. I'm gonna create one more on a duplicate that peace over here, which is going to be some kind of a corner piece. And I may be named this one C block. It's not actually going to be a C, but you will see what I mean in a moment. I'm gonna bring this over here, bring this over there, and I'm gonna take that last one, which is going to be the opposite and bring the stone like that. So this is going to be more or less a corner piece, which can probably sooner or later give you some fun in the game. And I'm gonna make this one fully white. So let's see, The point is going to be over here, so the rotation pivot point. So we're going to rotate this way we can rotate it this way and, of course, or the other ways as well. And that's ever seeing every block I wanted to create over here. So you keep track or take care off that the pivot points are 1% Lee correct at the positions where we want them. Make sure they're all snapped like all the boxes are snapped at the core, in positions related to the pivot point and then the next port. We're going to start to bring some life in the game. 13. #13 Moving Blocks Down: Welcome back to the course in this part. We want to create one new script as well as start work on the game mechanics. First off, we want to go into our assets, fold over here and create in your folder and call this one pre fabs. Prefab is nothing else later on, like a template on we laid on. Instead, she ate templates off something to make use of it. We gonna take care of the prefects light on, but I wanted to make sure that we have this folder already. Now we go to US groups for them and creating new seizure of script and called this maybe block or Tetris Block or something. Whatever you please and like like this. Let the compile a run for a second. And what we know want to do is we want toe select all our blocks we have created over here and the drag Ted Rose block on to them. We don't do anything anymore with them, but what we can do. Ah, well, I have selected the target the target does not need. So whenever we have all of these selected, we can create pre, perhaps already, since it has everything it needs. Where's the Tetra chatterers block script on him? So basically, you can bring them into the prefects folder. As you can see, you need to do this Separate Lee, like, one block at a time. Just direct them in and wait until overseeing has done so far. So we have these six pieces right now as pre fabs and you can see these have been indicated as blue non names in here, meaning they are related to a previous. You can also see this over here. So what we now can do is we can get rid of all these pieces. Maybe we're gonna later on take one of these pieces and make use of them to check out movement and stuff like that. What we know want to do is we want to open or whatever's block scripts or double click it and open is one in mono Develop this study or whatever I d. E you prefer to work with in our tenders block script. We gonna have to implement several things we can write down. Or you can write on yourself some your to do list if you like. Teoh, whatever. Whenever you create your own game, someone to make some informations insight. So the 1st 1 is going to be a float called previous time or Pref Time. This is going to be the time, which is the where the last block has been fallen down once. Also, we have another float which is going to be our full time. So the force or the forced time I explained in the concept video how long it takes until we force the field to fall down or the block to fall down. I'm gonna put industry effort for the moment. Later on, we can play around with these numbers based on the year. You're the experience. I get rid of that two commands over here. I don't need those. You can keep them in if you like Teoh. So now we can basically for us off recalculate our our tenders block to fall down. We can make use off and a core protein or we can directly do this. An update basically doesn't really matter. So let's do it an update. What we can do is we can calculate the time minus two previous time and when this time spend is bigger than the full time. Then we want to force the block the Tetris plop toe fall down one point like one step. So if time was a victim, he if time to time minus And once again we take the previous time we store the province time in a second If both of these values are bigger than the full time So the three seconds then we want to do the drop like drop down once. And how do we do this? We can say transform Don't position plus equal vector three dot down because we want him force it moving down What we can also do as we can afford the moment Maybe do it's a bit faster so every second block is falling down. Don't forget to save and go back to unity and make sure the compiler is done running. We can take any prefect. Now ignore the warning messages. They will be gone later. When we can now do is we can take any of our pre fabs, bring this into the scene anywhere and test our functionality. I'm gonna drag it a bit up over here. Don't forget to keep it snapped and maybe bring this anywhere where we later on probably will drop all over pieces. Maybe somewhere here we know press play. We should see everyone's a second toe. Bring this down. But as you can see, a just full throw because after that stuff over here, we did not reset or said previous time. What we need to do is after this if statement, we need to say previous time is equal to whatever the current Tinus. So time not time. Don't forget to save. Go back to unity that the compiler run and cross ply whenever it is done every second, the bloc should fall down one. Um, yeah, one position. But at the moment, it doesn't seem to do anything over here because we need to take the previous time and bring this after the movement downwards over here. Don't forget to save. Don't forget to save your scene whenever you're playing around with things and let's test it out once again. As you can see our little block here, even if it is moving wrong at the moment, it's falling down once a second by one unit minus starting just half a bit too high. It wouldn't fit the block Ashley, but now it looks correct. So once again, as you can see, it falls down once a second through the grid. But it keeps on doing this into nowhere. Well, we know want to do is we need to do some tax if we are still in the grid. Also, when we are unable to move, we want to make sure that we spawned a new one. And this able this Tetris block. First off, we need to make sure that we are actually moving into a valid position. And to do so, we're gonna create a little bull function. So the bull returns true or force, and we're gonna name this, maybe check Vallat, move at the very, very, very end. We want to make sure that will return True. So whenever everything air any pretax, do not do anything that we want to make sure that we return through at this point, what we now want to do is we want to live through all Ah, Axel child objects off our current Tetris Blanc, like all the many blocks, like, although, um, actual cubes want to make sure that all of these cubes do a match inside or whatever is great to do, so we need to create two more functions which taking care off that functionality, but that's what we're going to do in the next videos. 14. #14 Check Valid Move Round: Welcome back to the course in this part. I want to round the position movement on a check of the rounded position movement off our axle Tetris block. We gonna open on Playfield? We need to prepare that of it for self. We need to create a new function called awake, which is cold before start in awake. We want to make sure that we create a static access er for playfield. So we don't need to look into this the wall time and search the complete play or game until we find Playfield. To do that we create, which is called in single. We're gonna create it, Sell that at for us. We create a public excessive for them. Set this access er to be a static access er, then we call the name off the axle script, name or class name, and then we give it an instance name, for example. Instance in awake, we cannot say instance is equal toe this. So only play field is going to be represented in the game. Now we can create public functions and call just that instance and do all the calculations based on that, because we can now create all help of functions directly in the playfield if we want to. The first help of function we're going to create is a rounding function. We need to round our positions to full integer numbers to make all life easier to do. So we create a new public vector sri, and call this one round and we need to create one accessory or one input Vector three. And I'm gonna name a just underscore V for Victor. You can also name this one. Thank something like that, since it doesn't return anything at the moment we gonna have this red underlines were, but we want to return in a second. So what we want to return is a rounded of vector. So around it to a full introgen number. What we're gonna do us we say return new of actors, Ray, open close parentheses and first off, we call a mess f dot round to end. And what do we want to round is, of course, the x xsl HVAC dot Exe so whatever the current input vector is going to be over here, comma. Then we're going to do the same for all the other ones are gonna go on the next line, as we have done already. And the other one's gonna compete This board go here, I'm pasted into So we want to round here the Y value and in the last para media, of course, in here needs Apprentice E the last pair. Amita, we're gonna copy this. Gonna put another comma next line and bring in the Zad value from the vector. And since we know, return this vector, as you can see, return it whenever we requested. We always get in, return around it, vector toe a full intention. It's good, because now we can ask you take this as information and round every yeah, 0.5 numbers to be a full vector number. Now, we can make use of this in our Tetris block. So we go toe up Tetris blanc and then our Chiang developed move. We can now request this rounded value. In that case, we're going to create a new Vector three position. But before we do that, we want to make sure that we lived through all our yeah ships. So for each up close, parentheses transform. I call it child. So for child object in our transform So the transform off this particular cube, we wanna first off store each vector off each child and round its position. So we can say about the three p us for position is equal to. And now we can actually talk to our playfield. Don't instance the instance we just created. Now we call the function round when we get back around it. Victor off our side position. So we get always even numbers I like only the one or not even but only inter just like full numbers. 102356 100. But never will be a number in there, which is like comma something that's a good one, since now we can simplify our movement and process by checking fellas grid positions over here. Now, we can take this position and request if we are inside the grit. But that's what we're gonna do in the next video 15. #15 Check Valid Move In Grid: welcome back to the course in this part. We want to create another help of function inside. I want play field, which is going to be technique for us. If our child's objects on the position we are actually requesting is inside or outside our read over here like the Transform Vector to do so in Playfield, we gonna create a new help of function. It needs to be public and it just returns true or false. So it is going to be off type bowling. I'm gonna name this one. Check inside grit. You can name it, whatever you like. You can also name it. Check inside. If a field when we put in, it's a vector. Once again, we want to actually attack. If one's Pacific one is going to be inside the grid or not, I have a little type over here, so I just rename it check inside grit. So what we want to return at this point is the following. So the 1st 1 is we need to make sure that all of these are going to be full interview positions and vector on Lee has float variables. We want to get always into just back. So we need to typecast everything into an intelligent. So what we want to have is that first we want to check position, don't acts. So the input vector, if that is bigger than or equal than zero with what we can do is we can also take this number zero and tank. The grits transform the position X in this case, so that is bigger than that. We don't even need to round it. Or basically, we can round it. You can do it so that it is related to no matter where our transform grid is going to be later on, we probably change that. So it doesn't matter where our game object is going to be with. Since 20 over here represents a world access zero. We're gonna talk about this once again a bit later on. So if that's the case, So if my exposition is bigger or equals and zero end now, we're gonna typecast once again into another indigent over here. And position on the X is smaller than our grid size X. Then we know we are inside the grid like on the X position. That means we returned true in this case, we can also tank or we have to check at the same time. If the same stuff is happening for the why and for those that access for the why it is going to be a bit different. But for those that exists, it's going to be the same. So let's check those and excess next. So in that case, we gonna have another instill we're gonna do around here. I'm gonna missed one off these apprentices. So we're gonna take pause that if positive positions that is bigger or equal to zero, then we know we are inside the grid based on the world access once again. And of course, we're going to do the same for the grid size that so if the into general rounded or in this case, type casted positions that is smaller than the grid size that value, we know, of course, we are inside the grid. If not, of course, it returns true, not false. And and now we're gonna take the last one over here, which is the y value it type casted into GIA position. Don't Why, if that is bigger or equals and zero since that is going to be the bottom lane over here. So whenever we are basically on the bottom off the playfield, we want to return falls. Meaning we cannot move the Ted Rose block even further down. Don't forget to save. And now, in the tatters block, we can take care of that and check if we are inside the block or not, based on this little function we just created. So whenever we're checking for valid move, first off, we want to get around that position over here. So always a positive or yeah, always a full number. Then we can take this into consideration based on if not Ted Ra's grid, or in this case, it's Coldplay Field is not Playfield Daut. Instance the dog check inside grid and we gonna request Pew s So the child objects position is that it's actually giving us back of falls. We want to return false years. Well, but what does that stuff mean is we can now take this check and bring this into our full down functionality in the long run. It means whenever we do a move downwards, we can always make sure that we check if we are inside the grid or not, and to do so, we just can and capsule night the complete transform position Formacion into in a statement . So if check valid move is not correct. So if it is a negative one so in this case of it returns falls, then we cannot to do this movement and we would be able to sort we would actually stop that . So our transform over here of the downwards movement is going to happen first. Then we're going to check if we have done a valid move. And our proof this time is only tricking and ring a late on at the very end. So if we would basically not be able to do this downwards movement, we can also go and just don't do it or we just move it up again at the same time. Whenever this happens, we can also say that we disable the script this Tetris block script so we can't sent un abled is equal toe false. And we can also say something like create a new Tetris block over here and we can also track to delete a layer if we are able to delete layer if possible. All of that is now just related to one block or Ashley into any block. Also, if that is not the case, so we gonna have an else statement of a hereafter, meaning whenever we do half of Allah check, we want to say we want to update the grid like we want to update it by whatever the current position is we are actually at. Don't forget to save and let's see what our stone or block is going to do when it comes to the very bottom over here. It may or may not return the coric value because we're measuring against zero and rounded up or down. And currently we are in a position which is going to give us like a zoo 0.5 value rounded up to an integer. So as you can see, whenever it came down, it stopped at the very bottom over here because of just that. Vettel Check move and disabled as you can see the Tetris Block script at this point pretty good. So now we can go forward and do the rest off the calculations. One after another 16. #16 Check Valid Move Update Grid: Welcome back to the course in this part. We want to actually initialize our play fuel grid and update everything which is going to come inside the grid on which is moving inside the grid toe update positions. Based on that, you can also visualize that. But that is at the moment to not so important. That's open more Playfield script where we already have awake messages walls over to help of functions we want to do is enter very, very top in the start we want to initialize or grid. So we say boy, it start open close parentheses Make sure start is written was a big s since its ah unity provided function. So the wake message once again it's always cold before the start, no matter where it is in the script But you probably want to organize it this way. So in start we want to make sure that we initialize the grid by whatever we have said it before. We want to send it. The grid is going to be equal to a new transformer Ray. So new transform open, close a square brackets and then here we need to put in three values This revalues. You can predict our grid size axe comma, but its eyes. Why comma grit Size Zad That means we know have actually initialized. It was the values we were initially setting our grid up in the Inspector. Now what we can do is we can now, as it talk to the grid and put information into these transform values based on wherever X wind that at the moment is going to be. To do that, we have cause need to create another function which is actually updating the grid based on whatever the blockers were putting in. So what we can do is, first off, we're gonna create a new public. In this case, it's of time void. Since it doesn't return anything, we're gonna name it update grid. You can also name it. Update Playfield doesn't really matter for us, but we're talking to the great off type transform some. Probably That's the best way we're gonna put in one argument which is going to be off type Tetris block. So and we just name it, maybe block or tea. Whatever we now need to do is we need to loop through the complete three dimensional array for that we're gonna create for loops. So four and we're gonna start with the X value. So I got a name X or the interview attacks over here. Then the second pyramid is going to be the Mex para media. We're gonna put in route size X. Since you probably do not know how I created the fall of without typing out every letter, I gonna show it to you. I'm gonna type in four. That idea. Attempt the tabulator button on the keyboard twice. 12 What it does, it automatically creates this. And now I can put an everything for the letter. I in this case I gonna put in the zed value, which is going to be the, you know, the forward access once again. Are we gonna hit tap again and put in grit size Zad? Same for the why value. Since that is the up vector, we're gonna take care of that very last. We're gonna take the Y value end. Of course. Put it to be grit size. Why? So we now have three nested for loops. So first off, we loops Rex. Then we looked through that. So, like, left then up or forward. And then at the very last, we're gonna go upwards like one layer after another on the Y axis. Well, we know want to do is we want to check if the spot we're currently looping and is not empty or not Know. So what we're gonna do is if the grid so the greatest, the one we're currently talking to and here in open, close square brackets, once again, we gonna request the position we are currently at X coma. Why commas that once again, these three values are the values from the four loops over here. So these are, like coordinates in the ex wives that coordinate system. And now we can actually request if the parent at this positions of the transform dot parent Basically, it's a transform off. This type is going to be equal to our block dot transform. We're gonna need to put in equal signs. And if that's the case, So if the grid x y Zatz of the transformed or parent, whatever the transform is which is currently sitting inside this particular grid, if that the parent of that is going to be our own transform so that the one which we are requesting from the current block. Basically. Then we want to reset that or we want to make sure that we set this one to be equal to know . So we can say the grid in square brackets X comma Wycombe Azad is equal to know. So we empty that out. That means we don't want to have the parent objects over here who only want to have the child objects basically. And to do so, we're gonna need to off cause go and check for all the blocks transforms to do so we're gonna create a for each loop. Since it is easier over here to use for each So four EADS off type transform, I gonna name it a beef or block in block to transform. So basically, for each child in the block Trans am I gonna maybe not name it Abeba Child! So once again we want to update now all the the child's off the requested block and not the parent. That's why we have this one over here for each block we wanted first round the position again. So we say vectors, reap us is equal to round. And now we want toe round again the child's dot position. Then once again, we tank. If we are lower than the y values of the maximum via why? Well, you. So if pure as Dodd, why is smaller then our group size? Why? So we at least dropped once or twice. That is the case only then we want to make sure that we put this inside the grid. So we update the grid by the child position over here so we can say the grid. And in a square brick, it's we gonna typecast this even if I think we don't need this into an Integra. Round it to be into pause X comma once again open close parentheses in So once again, typecast positioned out Why comma And once again, at the very last week in a typecast ah, position. I thought that into a full interview over here and put this into the great and we want to do is we want to set this one be equal to child. So the child we're currently actually going through because once again, this is of type transform as well, and our grid is type transforms so the child can fit into the transform. Very good. So now we have all the parents get. We get rid off the parent objects and we only fill in child objects if you want to, you can always make command over here. Delete possible parent objects. And here, Phil, in all child objects, like all child objects, we're gonna have inside a wood blocks. Once again, the parent objects have the objects where this Tetris blocks on. But the child objects like all the four quads or cubes inside this want is three for these other child's we want to implement or in your put in side, our grid over here one that we are actually updating the grid. We don't want to have the parent objects because they're basically just empty ones. And we can late on if we like to even throw them away. But we would need to put away the tired objects over here as well, but that is not really necessary. So we are great. The grid or update the grid. Whenever we call this from whatever the Tetris block is, we're going to request in an export. We gonna make sure that we finalize that port in side the Tetris block 17. #17 Tetris Block Update Grid: Welcome back to the course in this part. We want to continue to work on the Ted Rose block again. That's open this one up in mono developed this just studio whenever you please. And like, as you can see, whenever we have a valid Murph, we want to update the grid with our current position off the current Tetris block. To do that, we just call playfield. Don't instance, don't. I'm date grit. I want to update the grid was the block we're currently at, so we can pass in this. This is a special key word which is going to be related to whatever the current script is we're going to have over here or we can also do is we can prepare late on to create a new object at a specific position whenever we are not moving anymore. So we spawn a new tile or a new tatters block Peace over here 18. #18 Check Valid Move Get Grid Position: welcome back to the course. This part of we want to make sure that we check if somewhere in our grid already is a piece which is or has been updated to be at this point, that we're not able to move to the position where this is going to be related to. To do so, we're gonna open on a play field script once again, and we need to create a new phantom, which is also public one. So we can't access it once again from outside. I want to do is we want to return a transform, and we're gonna make this one based on a vector sri position once again. First off, we want to request this. So if at a specific position, there is another cube already sitting like a mini cube to do so we named this maybe something like get transform on grit or something similar or great position. So I wanna request one specific position on the grid or inside our grid and see if that is taken or not. And based on that, whenever it is correctly set it up, then we want to return. It is no or will return something And based on this, whatever we return, we can also check for valid movement. We need to do this to compare if we can move to a specific position or even rotate to a specific position. Whenever we do that to disown once again, we're gonna put in a practice. Ray, Name it Pew s. So this is the position we want to check and we want to check it first is if we are in the height off the grid, so meaning if appear as don't. Why, If that is bigger than our grid size, Why minus one? So we are at least inside the grid. That is the case. Then we want to return now because we are outside of the grid, so it doesn't make sense at all. So we return? No, we also want to do is if that is not the case, as so we actually are inside the why. Well, you we want to return whatever we find, So it can be no can also be any transform. Basically. So what we want to return is the grit in square brackets. And then we take around the position from this once again based on the position off the thanks. So in that case, we type casters once again into an interject because the grit only contains into just anyways. So we say pause, X comma. And then once again, typecast into an inter Gia paused old Why comma and typecast us again into an integer pause Don't sent. So we returned this value When there is nothing inside, we return now, Otherwise we return Whatever's is inside, whatever the transform inside of that grid is going to be. Why do we need this? Once again, we need to make sure that we can not intersect something by checking its valid movement over here inside the Tetris block. So to update now, attack valid movement over here. We're gonna create another for each loop After this. First off, we want to make sure once again that we are inside the grid. If that does not fire and does not throw us out here, then we're going to do the secondary tank where we are and if we are able to move inside. So in that case, we gonna loop through all the tired objects once again. So four each transform child and transform so basically we're gonna do the same. Repeat that step, but we're gonna make sure that we clean it up completely. First off, we want to make against the rounded type position per it aeration. So I can basically copy this part off this line. Then the next one is we wanna actually call or request the transform from the function we just created are gonna name it t for whatever the transform is. And we now call the function we just created. So transform t is equal to And now we talk to the playfield once again dot instance don't. And now we want to get and the transform on grid position. So transform on grit us. We pass in Pew s So the rounded position over here and save that now inside T now we can compare t against whatever we want. For example, of tea is no. Then we know there's nothing. So if t is actually not equal to know end And now we can also request a teeth parent. So basically ah, us ourselves. So if t don't parent is not equal toe ourselves so transform. Then we can say we return false. Otherwise, once again, we're gonna go later on and return. True. So what we're gonna do here is, if that's something on the position, but is not our own position, basically. Then we return false. Otherwise, we returned true in this blockers actually free, so we can actually do a valid move to this position. We gonna need this functionality completely over here inside the taters blocks. So every taters block can check for Melo Move, no matter what type off input he's going to do later on. So whenever we're starting to move the blocks into one or the other direction doesn't matter which one we wanna make. Sure. Once again for us, we are inside the grid. And then there were not intercept dissecting our self. Plus, we are not intersecting any other already existing blocks inside the grid. 19. #19 Block List: Welcome back to the course in this part. I want to update on a play field so that we can dragon all over blocks inside some kind of list. And we can. They don't randomly pick from the list which one we want to incent e eight or create. And then we can actually take care of off there that we are able to spawn new blocks whenever the other one, whichever way have before is not able to move anymore. First off, open on Playfield script and we're gonna go and create a new function for that later on about movement. What I also want to do is I want to take this great size x y that and bring this under over here for their port. I want to create a little header header is just a visual representation inside a war inspector where we can literally do are put some spaces or give some names and stuff like that in the inspector for us to see stuff easier. So in square brackets had a home, close parentheses and in quotes, we can put in any name something like Playfield visuals or something like that going to show you what that does. So you get in understanding what this is about. So whenever something is a buff of the header and below the header, the header is going to be shown. Otherwise you get in a row. As you can see, I just put it in the grid size X y and that in here. And the Playfield visuals are only these planes. Now what I know also want to put in is another header which is representing by all our pieces. So a list off all our pieces and we're gonna have another headed. So we see that stuff better. We can also put in a new ray. Basically, doesn't really matter. In that case, I gonna put the header with its playfield visuals below. Then I gonna create another head over here. Call it. Header was a big age Open those parentheses and in quotes are gonna put in something like stones, oil blocks or whatever you're pleasing like Later on, we're gonna have another one which we are going to talk about later. So in that case, we can Now we need to make sure under a header comes a public one. We can once again take a list or an array. In this case, it doesn't matter. Can make a game object array over here and name it Blocks or block list off block array blanc. I don't know. List. Once again, you can also take a list. Doesn't really metaphor that part. And what it does is it creates another header and a public array off a game of jacks where we can put in all our blocks scan, see wherever blocks header the block list size of zero. We now conducive can take all these pre fabs and direct them in here. Make sure you only have one off eats in the list. There's also the possibility against toe. Select them all at the same time, but we need to lock those selection over here was a little lock symbol. So we can basically fill in all this one's at a time or basically, with the complete selection inside the block gonna show you if we're going to reduce it to zero. Then off course nothingness inside again. I take the lock symbol, lock my inspector, select all of the's and bring them inside the local block list Over here over the name you can see no everything once again is insight. I need to make sure that I disabled the lock symbol so we can keep on working on the play field. Since we have no old blocks inside, I will block list. We know that we can pick from them. And instant she ate any random piece from this particular lock list. So we can just calculate any in next, like something between zero and five at the moment or whatever the amount later on is going to be. And then we're gonna pick, Let's say this block by this index. So in next to then we would representing what? Ask the yes morning and El block. 20. #20 Spawning New Blocks: welcome back to the course in this part. We want to create a spawn function which is actually spawning one off the pieces from our block list somewhere over here at the top. To do so, we're gonna open on a play field script. We need to create a new help of function for that because it's easier to excess. And also, it needs to be a public one. Since we want to talk from the old Tetris block was has been landed to that to spawn a new one. So we're going to create a new public wide spawn new block. I'm grows parentheses itself type void. Since we don't return anything, we just do stuff. First off, we need to calculate the spawn point. Where do we want to spawn our Tetris block to dissolve? At first we calculate the point based on the vectors three. And what we're gonna do is we're gonna name this one. Maybe spawn point or spawn position doesn't matter. And this is going to be equal to and relate to our spawn point possession or our transform position from the Playfield. So what we can do is where you take the maximum height. We need to round it to an integer, of course. And then we need to make sure that we take half off the X and half off the sad value so we can actually make sure we always rounded to the correct yes size and we are able to bring it to the court position. So let's do that. First off, we need to create a new Vector three and then here we gonna need to calculate for us the exposition. So once again, expositions from left to right. So first off, we want to make sure that we typecast and this one into an interview. So we get a full number. Are we going to take? I want transformed a position, the decks and then we add once again grid size accident. Divide this by two So great size X, and divide this by two. And once again, we need Teoh typecast this one he into a flute Since otherwise we would have a strange behavior and ah, and the calculation would be kind of wrong. And then later on, once again we type cares this one into an interview again. So we have a full number based on whatever came out. So next one is going to be the why will you? Once again, it is going to be the height we can adjust. Renda Mayes That Or as you take the height off the current height, plus the grit height in this case. So we gonna typecast this once again into an integer And we take once again the transform dot position doing to why and we add or group size Don't y to it? Simple. Now we have the last one, which is going to be the sad value which you remember, probably as well. It's basically nothing else than I want X value, but only and the at that access. So we need to typecast this into an integer we're gonna take transform the position, don't that? And we add type casted flute off. Grid size Azad divided by two. So this is now going to be our spawn point. Once again, you can also type this all in one line. Doesn't really matter for the coding over here. Now we can actually take any random in next, which we can calculate over here later on. We probably take a pre calculated index when we gonna do something, like reviewing a block so we do the calculation somewhere else, and then we're gonna take care of this one later. So in that case, we gonna, for the moment, take a random index, as I already explained, and we do this or calculate this random index by random dot range between zero comma and then the maximum size off all the block list or the blocks inside a wood block list so we can say block list don't lengths. So the maximum lengths over here and since the length is different currently has a length off sex brought, the last number is always going to be ignored. So it's going to be an index between zero and five. And that's correct. And so when we no need to do is we need to yes born the actual block So we can say we spawn the block here. We already have which block we want. And we have this born position some more is not needed at this point. So what we're gonna do is we create in your game object se knew block is equal to in San she ate of goes Prentice ease first off. What do we want to instance? She ate is based once again on the random index from our block list again. So we can say block list in square brackets, random index. So whatever the index is, this is the object we want to spawn. Since this block list, off type game object. Now we can say, what is the position and where we want to spawn That is going to be on spoon point. And the final step is going to be the rotation. In this case, we just take quit Ernie in dot identity and after the parentheses. We need to typecast this as a game object again. Otherwise we would have an object, and that would be wrong. This parentheses is not needed over here, so we just safe our script right now. We're going to do some extra stuff over here later on. So I'm gonna make a little ghost stuff over here as well as we need to set some imports later on at this point. Yes. Well, now, what we can do is from the Tetris block whenever it has been lended. And there's nothing else to do over here. We can basically create a new Tetris block so we can now talk to play field door instance Don't. And now we're gonna say Spawn New block oh, close practices and close the line was a semi colon. Now we can test it out. We gonna let our compiler run, make everything correct, and whenever our TPS is going to land on the ground, you can see it is keep on spawning new blocks. There's another reverence exception over here, which we need to check out pretty quick. That's one more small thing we forgot into one update grid function. That's where there's no reference for me coming along once again. Also, you can only see this whenever the consul's open. So what we need to do is we need to go and open a wimple update grit function. In our Playfield script, we need to add one extra line, which is checking if the currently tanked field is not equal to know so otherwise it cannot check against parents and block transforms, because whenever it's no, it doesn't return anything. In that case, we're gonna put in the grant in Scrabble. It gets once again X comma Wycombe Azad, if that is not equal to know. Only then we want to go forward and do check against the parents inside this. So I'm gonna take this port and bring this No. So I paste it or copy or actually, I cut it out and bring this in here. So once again, first off, we need to make sure that we are having not analogic over there. Otherwise, we break in suddenly out of it. And if we do and find something over here, then we can only take care of the parents. That's the problem we just had before. Don't forget to save the script. Don't forget to save your scene. If you have done any major changes and stuff like that on now we can do another check. And whenever our peace is going to land at the bottom, we should be able to create a new block. I want to see where this position is going to be. There we go. I'm gonna pause the game. As you can see, this this block is no created since its pivot point is over here in the center, it is basically centred toe a play field in as you can see in the why. Well, you are in this that value then in the X value, it is also centered. And of course, it is going to be at the highest. Point was created like those two blocks have been basically outside over here, so I can actually bring this up. This is the spawn position where it came from. Once again, this is the pivot point, and it is going to be centered completely correct. Based on the position off our yeah, Playfield over here. That's good. That's what we need and wanted. And now we can also let this one fall down and see what's going to happen whenever it drops down and whether it goes toe, you can see it already lands on the pieces it finds over there. And of course, we're gonna get stuck at the precision at a specific point over here. 21. #21 Spawn Block Position Fix: welcome back to the course in this part. We want to make sure that whenever we are spawning a block that it is correctly said it based on the position best Lee on the position off our transform block over here. So we need to round it correctly to the position where we want to have that. Well, we no need to do is we need to make sure that in our playfield, wherever we are sporting on new block over there, are we gonna typecast is completely correct. In that case, currently, only transform position dot Exe got type. Cast it into an integer, but this one did not. Since this return to common number we need to do is we need to a port, another pair of Prentice's around the complete calculation So we can now typecast an integer around the complete result off all these numbers. So this one here does not need to be transformed again because this is the full into Jen. This is a full integer. But this part over here needs also be once again encapsulated in a complete pair of Prentice's from the complete calculation like that. So we're gonna have the typecast to the complete everything which is coming afterwards. Inside the pair of Prentice's calculation, don't forget to save your script. Let's go back. Let the compiler run and see is that fixes are respond position? Yeah, problem. Actually, let it drop again in see what the next tile is going to do as well as what this tile is going to do over here once again. Currently, we are not relating the dropping based on the position over there. But probably we should do that. So, as you can see No, this eyepiece came down and it is now at full Pyramid is like full 262 in Austria, access everything is now a straight number and also, when it just goes on, drops down, it's going to do all the other ones as well. And all the other ones which are coming downwards are also correctly seen over there. 22. #22 Movement Input: Welcome back to the course in this part. I want to start to work on the movement off our an Tetris blocks for stuff we need to create a new function inside of a Tetris block. This function once again, we'll just take care off basic movement based on an input vector, for example. Lecter, UMP, Connector down. Work the left, Right forward whatever vectors we're going to have over here. So first off we create a new Voigt. But I want to make sure that is going to be a public one. Since later when I want to Excess D's from buttons as well Tell the public point set input we can set any important later on based on a vector vector Three off course, We're gonna name it something like direction. So we have four directions where we're where we want to move to, and what we want to do is whenever we sent this direction into this, we want to manipulate the transform position off our block. So we sat transformed a position plus equal whatever the input directs and vector is going to be so whatever we are going to input is always one in one direction like, is it one to the left? Want is right. One up or forward or one back Watts We also want to do is whenever we had done was that we want to shack if that is a valid move or not, if that is not a valid move. So if not Jack, develop, move. We wanna get back where we came from. In that case, we're gonna say transform dot position minus equal the direction which we just put it in otherwise, so else. So if we are able to do this move, we want to update the grid with our newly created or nearly moved block. In that case, we're gonna call. I won't play field door. Instance. Don't update grit. I want to update this grid with this. Great. I always this block. That's it. That's what we need just for the movement itself. Now we just need to talk about how we want to do this inputs. Once again, I'm aiming for buttons like whenever we have a flying Ken. Was we gonna put one of these buttons? And based on the input off, these buttons were going to say send the direction inside of here you can also do. There's an update if we like Teoh if you want to, since all the other inputs are based on the same content. So for example, what we can do is we can give any input over here like a Rocchi's or a SD at W. If you like Teoh, whatever the input is, you can take this and make use off the set input direction, for example. I'm going to give you one example for this. So if input don't get key down, so whatever the key is and when we need to do is we need to put in any key codes, don't something. So, for example, we gonna take left a row like this. If we are taking the left arrow on our year windows keyboard over here, we gonna put in open close curly braces. So if we are going to ah, take and left arrow input, we just need Teoh call set input and put in any direction Vector. We wanna actually send our stone too, or our block to so we can say set input and always just put in something like vectors Tree don't left and that's it. More is not needed Once again, you can repeat this for all the other ones so we can basically do a free movement if you like to. So you just copy and paste all of that. And in here when we are saying OK, we're gonna take the right arrow over here, then we're gonna put in Vector three, right? Whenever we are, like taking the up a row, then we're gonna say forward. And when we are taking the down arrow, we're gonna put in back. So basically, this is a keyboard input, which we can absolutely make use off even if we don't or I don't want to. So if you want to make use off keyboard input, this is the way to go. I'm gonna show that. So you're gonna get an idea about this Gonna press play. You can also set up multiple keys. It'll is up to you. So whenever now I press any button like forward and backward and left and right. I can basically put in thes little pieces to any position I like to We can't do the same. Was the rotation vector later on as well? So currently is a bit on But as against see, we can now steer all these pieces to whatever the positions are we want to set us into. And then we're gonna be able to allay their own check if we are able to, you know, clear a layer. But that's what we're gonna take care of it later on. So for the moment, we have some basic inputs resin simply done in the next part of we gonna take a look into rotation. 23. #23 Rotation Input: Welcome back to the course. This part We want to take a look. Answer how rotation works. They're a couple of things we need to keep in mind, because whenever we do like a three way rotation like exploitation wire rotation and Zad rotation, we don't have much keys. Or maybe not the best keys on your keyboard because currently were rotating the camera with the right hand. Like whenever we are one, you know, dragging the mouse around so we don't not or cannot basically be able to use the keys like abdomen left, right arrows. We just created in the last video to do a good workflow, a good play that, say feeling. We want to make sure later on that we only do mouse inputs, but for testing purposes are going to give you an idea how all of that stuff works. Let's assume we gonna make use of this keys also. But we're gonna get rid off these imports anyways, so or you can also go and take any other year inputs over here like ex wives, that whatever or other keys, you are going to take a look at it. But since we also have negative rotation possibilities like we can rotate left like clockwise and counterclockwise. This is not a good solution at all. Or you only limited toe do the rotation in one direction. Like always, you need to rotate four times until you're back to where it came from. And sometimes it's not a good idea about to do that. So we created a new public function off the void. Since we don't return anything and in this case, we gonna not just do a move input, we're gonna do a rotation in port. So I gonna name this run rotation input, and what we're gonna put in over here is also a vector, as we already have done in the other input. So and this one, I gonna name this one rotation open calls, curly braces. And what we don't want to do is we want to rotate or peace. And to do that, we can't just make use off, transform thought, rotate and in rotate. We only need to take one vector in this case, as you can see, Vector three Youlus. So in that case for us off, we want to make sure that we use the rotation vector were passing in, no matter which one. The point is, when we do this, we only have a local or space rotation. And that means that the input as always, going to become wrong. We want to have our rotation based on the world space. In that case, we say comma space, not self, because self is the one which is usually on. We want to go to the space. Don't wilt the 2nd 1 This is absolutely crucial and important. Just keep that in mind. So once again, now we're gonna do our fellow check once again. So if not, check, develop, move. So it doesn't matter if we're doing a movement check or a rotation check. If we don't get a relative move, we want to rotate back. In that case, we're gonna copy this line back and bring this over here and negate the rotation vector. So we say minus rotation, we still rotate in the world space absolutely important over here. Then, of course, we're gonna do an else check. So if the rotation was correct that we want to update all play field so we can say playfield, for instance, don't update grit open close parentheses. Enclosed the line was a semi colon. And inside. We're gonna put in this particular block. We want to have updated inside of a here Pretty good. Don't forget to safe, and that's everything about rotation. Now, we just need to call the rotation based on the factor. Okay, so let's assume we're gonna do the up arrow now for a X rotation. What we need to do is off course. We need to put in the correct of vector in this case. So let's assume I gonna take my up vector and rotate upwards like four in the forward, like, you know, in the forward direction, the like in the that direction, but over the x axis. So how does it work? Is we gonna say set rotation input over here? Once again, I gonna command or the other ones out here because we don't really want to make use off the update loop for this. I mean, you can ah, you know, know how it works. You just need to put the correct keys. You want to make use off? You can also put all of that in a S. D w. Something like that. And to the rotations on exit at CV. Whatever keys up to you once again, I gonna show you the other way with the buttons a bit later on because we basically just call the same functionalities from these buttons or functions which are accessing this particular. But you're Tetris block over here. Okay, So what we want to do is we gonna sent the rotation input of the here like once again over the ex excess. In this case, it's going to be a rotation 12 vectors. Three dot left. Could be that. It also is the vectors, read or write. But let's assume it is the left Victor. So let's check it out. So whenever the compilers done running and I hit the up key, we should rotate. But it is rather slow in this point, since that only returns a number off one. We gonna need to declare this vector translation a bit different. That case, we're gonna create a new Vector three like that. And now we can put in any vectors in here. So we thought with 000 And since we want to rotate about 90 degrees, we're gonna say, OK, we want to have an ex rotation off 90 degrees into the forward. Excess could also put in a negative. So we would go and roll backwards like was the down key. For example Gonna copy this and bring this over there? We can also say this is going to be a minus 91 were pressing the donkey. So we basically do the opposite. Let's do the compiler run over here, press play. And now, whenever I hit the up key, I gotta point this way or I'm gonna rotate the other way and you can see I can keep on rotating until I hit the ground and I'm not able to do anything you can see. You can also at do this with the cube itself. So or even with this l pieces you and ever saying can now rotate off course, we're gonna lose rez. A simple And that is everything about of rotation. We need to know about 24. #24 Movement UI: Welcome back to the course in this part. I want to start a create every input possibility about buttons directly form for each stone . We're gonna do some special set up, which is going to automatically late on hope to the next piece over here. And also, whenever we click from the bottom or from the top, or wherever this button we're going to create is located, we gonna have a reaction. First off, I would like to create an empty game object which is taking care off of the position and everything else related to that. I'm going to reset this one, though. It is going to be at 000 over here if you want to. You can also give it a Nike in. But you don't have to. For example, this one I'm gonna name my game object. Something like input Holder. This import holder once again will be repositioned later on and also takes care off what is going to be active and inactive. So we're gonna create a script for that stuff over here as well. The first thing we want to do is we want to create. And you I canvas this canvas is usually set to be screen space overlay, which you can see in the inspector and screen space Overlay is just a huge and also not in the correct ankle. I want this to lay down around my input holder object so it can also lay around my block later on what I want to do. They want to change the canvas so that we can make use of it and locally, depending where and how we want to. To change the canvas, we need to go to render mode and change it toe world space. So it's just sitting somewhere in the world. We also need to do is we need to change the event camera to be our main camera so you can present the small dot go to scene answer for select the main camera. Everything. Els is not important for us at the moment except the size and the rotation off. Let's assume I wanna play Field over here is going to be five by five an hour. Block usually is not higher than four by four, depending on how big these blocks are. What you want to do is you want to have this one at least a let's say eight by eight field around our block. So let's do that. First off, I want to take the canvas and make a child off the input holder so I can make the position related to the import holder. So I zero this one out first, so it will be somewhere here. Also, I want to reduce the size for the moment to eight by eight. So these are units eight units by eight units. You can also see that directly on the grid over here. Also, what I want to do is I want to rotate this one by 90 degrees back wants you can also do it forwards basically doesn't matter. So in that canvas I want to put in all my buttons to control the axle block to do so. The first thing is off course. We create a button. This button is going to be rather huge. So we need to ask the resize it since we're using the mouse and we know that this unit and the other one is a unit. We probably change it for the moment to two by two. If two by two is too small, you can always go and make it bigger when you know a dragon around like on the right side of the screen. Or in this case, off the canvas, you can see that little gray line of the you can check if that is too huge, all too small for us input. Now, what I want to go is I want to change the Sprite toe one off my sprites. Since I don't have any sprites defined, we go to Texas and take these two arrows by holding down control. So like them and we want to change them to spread to the u I and apply the changes. Now they got a transparent background and the guard a actual sprite which we can now drank into a button. So now we're gonna change us toe a narrow. As you can see, the quality looks quite OK. So this is going to be our X button, as it can also always see over here. So four x based movement. So this canvas, by the way, is what we want to rename to something like Move, Can this because later on, we will have several canvases over here. So this one once again is the positive X button. I'm gonna name it X p us for X positive. I can also duplicate this rotated by 90 degrees and snip There's to the other side off my lay out of here. This is going to be my ex Negative button. So I name it X and E g. Negative. Now we need to also have something a lot for those that value so we can move our stones into that direction, as it can always see at the coordinate system. Over here in the top, right corner off the scene. You So we need a positive That and negatives at Aero s. Well, so in that case, we just duplicate posts, control de them. We go to center because we have to solve like that too. Then we hold down control and snap rotate around the center. Now again, just go in. Go back over here to pivot point. So we only have one of these pivots. Most of the time, the first elected ones pivot. And here we just rename this one. Since this sister that negative are gonna rename this to that neck. And the 1st 1 is going to be that positive? This is for us later on. Important. So we easier find what we are actually doing at the moment we now can do is we can create functionalities for these buttons as well as bring the input holder always to our Tetris block, whichever is active. But for the moment we're done. Was Dad over here? 25. #25 Rotation UI: Welcome back to the course in this part. I also want to create the rotation canvases. Ls three different canvases we need for rotation since we're gonna have a exploitation A Y rotation and Azad rotation to to sell, we can, for example, take the move canvas and just duplicated control. D rename this 12 maybe rotate canvas X. What? We want to do it. Since we want to rotate over the axe access, we wanna bring this like this. Why is it the correct one? Because we are rotating around the X axis. So around this excess, which is going to be this way So what we want to do here s we gonna only need two arrows for the exploitation. You can also always go and bring in more. So for the moment, I again I get rid of this one. I also a get rid off this one. And what we can do is we can take thes and bring them somewhere wherever we like to see the rotation for the X values. We can put this on top to actually do a rotation this way. Maybe that's the best solution at the moment. So let's drag of the buttons to that. Once again, we hold on and snap until we are over here and we're gonna bring them to the center. Same for the other side. We bring them up first and then to the center. Since these are rotation, once we gonna change the arrows off thes so I'm gonna change them to rotate Aargh. And this one also to rotate around. What you see is that this one is actually wrongly rotated. So we're gonna do and negative rotation Hoover years. Well, if you like Teoh, you can always leave some space. And between those arrows, so they're probably easier to see. It's just some slide bit. Don't forget you don't want to do the text, but the button itself something like that. So it's easier to see and easier probably to touch and not to miss. Since we do have these sex elements of a young our buttons, we can actually go and delete those just like them and hit delete. Same for the move. Can was we don't need those tax elements over here, so nothing needs to be rendered extra because we don't need it again. Now let's rename them So this is going to be the Xnegative Journal rotation. And this one is going to be the X positive rotation A button, actually. Now, what we also want is we want to have some rotation Ah, Fouras of that and the y value. We can once again decide where we want to position these. Gonna disable the move, can associate we can see stuff better. So once it's once again assume. Or let's assume this is always flying over the rotation point off our currently selected tile or block. When I bring this over here to the pivot point off our current selected or currently active block, you can see how this is going to look when we want to have us of a years. Just another one where we can rotate over the wild access in another one which lets us rotate was is that excess Once again, how you put that together is totally up to you. Same with size, design and anything else. I'm gonna take the rotate canvas X and duplicated completely and bring this over here. So this is now going to be our rotate. Why, actually, I maybe don't like to have the arrows over here. But maybe I bring them over there once again. That's a total design decision up to you. I don't have to do anything with that. I got a name. The rename. This one. Toby, Rotate canvas. Why, This one is going to be the wine negative button. That should be Well, no. I guess this is the why negative. And the other one is the Why positive. We gonna check this out later on, anyways? Because we're going to create some functions which are going to take care off that. So I'm gonna rename this one toe. Why? Negative in this one, Suit B. Why positive if not once again, We always able to change that later on. So in the final one is going to be for the Zad access so we can actually take the X canvas once again with duplicated rotate, snapped us to the right and rotate snapped this to this site. So in that case, this is going to be the Zad rotation. As you can always see. Once again, we have rotating around the Zad access this way. So to do so, we can actually also take our buttons over here. First off, we renamed the Gamblers to be our Zad rotation Canvas. This should be the positives Ent button. So I'm gonna rename this one to be poor as that positive. And the other one should be the that negative once again over here as well. If that is wrong, we laid on just change the behavior off those. So back in this mode, we can assets. See, Now we have three possibilities to rotate our peace. I want blow. Cornerstone. Now we just need to create the code which is a doing all the work for us inside or input holder. 26. #26 Mini Clean Up UI: Welcome back to the course before we go in. Create the script for that. I want you to make sure that your input holder, which is currently over here but the pivot point is actually shown for meek and not correctly. I want you to make sure that you all your canvases are over here around the input older, which is for me this little check mark button. So what I want to do is I want to reposition everything of here 2000 in X wines that coordinates Do not resent them because it will also visit the rotation. Don't forget to save your scene and then we are good to go Toe asked me do the coding? 27. #27 Reposition InputHolder: welcome back to the course in this part. We want to start her to create everything about our import holder and, anyhow occurred get, anyhow our connection to our current Tekla rece block, as well as updated accordingly. For stuff we go into almost scripts folder and creating new see ships trip, you can name this whatever you want. For example, button inputs. You can also name this one item holder or input holder in this case up to you. Open this one up in mono develop or visual studio or whatever I d you like. Once it's open, we want to change the start message to be an awake message, and we're gonna keep update, since we probably know we will make use of that. First off, we want to make sure that Button Input is becoming ecstatic instance, as we already have done to all play fueled. So in that case, we say public aesthetic on button inputs. Instance. So instance, once again, it's the instance name to excess it in a wink. We just set instance to be equal to this so we only have one instance over there. Once again, this is called more or less a single we need to do is we need to actually change or get access to the move canvas as well as to all the rotation canvases. In that case, first off, we create a public game objective, Ray. So game object, open close square brackets. And we're gonna name this rotate canvases or something like that. Also, we want toe Xs the move canvas. So in that case, public game object move canvas. Well, we know want to do is we want to know what is the actual active block. So we also need to store those into game of decks or even Tetris blocks. In that case, in first, create a private game object. Call this active block. We don't need to set anything over here. We're gonna do this by coat, and we need to have a connection to our Tetris block, which basically sits on active block. So I'm gonna name this active Tetris. What? We know want to do it. We want to create a reposition functionality. So it is off time void. I'm gonna name this reposition to active belong. So we want this button input holder once again. As I explained before to follow whatever the current active block is going to be. What we first want to check is, of course, if there is any active block. So if active block is not equal to know, we want to say transform. Don't Position is equal to active lock dot transform dot position. So now we just need to make sure that we, anyhow, excess that And in that case, we gonna make use off. Well, I'm dead so we can call reposition active block in updates. Whenever it moves, it lands or goes anywhere else. We're gonna update it accordingly. Now we just need to create an excess er to bring in active block and active Tetris, so we know which is going to be the active block. 28. #28 Reposition InputHolder 2: welcome back to the course in this part. We wanted to make sure that we gonna who actually sent to the active block to our input holder to do so. We're gonna go into a want Tetris block. So what we can do is, for example, as whenever we're creating a new one, we can set this one, Toby, actively, actually set. What we can also do is we can set this in start meaning whenever we're starting with a new Tetris block, we gonna get this tenders block and bring this to our button input. In that case, we just can activate button inputs, which is going to be once again my sessions grouped daughter instance and now we can actually excessive. But we don't have a function to do this. So we need to create this. We go toe a button inputs script, we gonna give out some space and we create a new void, sent active blanc, open close parentheses and also opened those curly braces. We want to make sure that this is going to be a public function. Otherwise we cannot excesses from Marwan Tetris block, we now can pass in is a game update or be the act of Tetris, or we can also do boats to do so. We're gonna type in game object blogged comma and in here we can also pass in Tetris block . I got a name, it maybe t block. So what we now can do is we can sent the active block and the active Tetris, Toby Block and T block. So in that case for self, we're gonna set active. Long is equal to block and active Tetris is going to be equal to t Look, not really me rename this pretty quick because it's actually strange. I'm gonna just name this one Tetris. So instead of tea blanc, I'm gonna make it Tetris. Yes, well, that's everything we just need to do over here to bring in all this information. Now we just need to go back to our Tetris block. We want to actually sent the active block. Don't forget to save the button input script by the way we want to do is we want to go and get this particular game, object where we're going, or where we are actually in and sent this into our block. So we just pass in an object comma, and now we just need to put in the Tetris block. In this case, it's this. No, we have sent away instance to be equal to the game object. This block currently is running on and to this script we're currently trying to excess or we want to access. When a new block is going to be created, it will override it automatically. Let's test this out. First off, let the compiler run in unity and see if we have no problems at all. Then we go to input holder and drag our button inputs over here when we can also do us, we can already put in all our rotation canvases, explains that into the rotates canvas missed. So just direct them in and saying for the move, canvas will land in the move. Canisius. Well, but for the moment, we only want to make sure that this import holder is always following are currently active block Also, when new ones are created, we want to overwrite them and bring them to the next one. Clear The consul I gonna save my scene and I press play. So as you can see, this input is now following completely up over here. And once it lands and the new one is created, the import holder is again following up, and we should be able to click on these buttons. Meanwhile, they're going downwards. We're gonna need to do some settings for that. But that's what we're gonna take care off in the next or one off the next videos. 29. #29 Moving Blocks UI: Welcome back to the course in this part. We want to go forward with the inputs and for now, create the functionality for all our movement buttons. Let me deactivate all the rotation canvases so we can't see better What's going on? First off, I might want to go and change all the buttons colors. I want to make them so that they are not fully seen the wall time. So I want to reduce Al for quite some bit, maybe up to 75 or down to 75. Also, when I want to collect them like the pressed color, I might want to change his one to something slight blue. You can change that to whatever your needs are as well as the fate duration. Maybe I gonna lift it a bit too. 0.25 Now we're gonna create it in a click function, which is taking some indicators. So it understands what But then we have pressed and how to move or block. To do that, we open a war button inputs and create a new public function for the movement public. Avoid, move, block. And since buttons directly and the on click events only understands into float and strings and only one of these we gonna make use of a string. A string is just a text. So I'm gonna give it some direction, which I can compare now, depending on the direction we're putting in, we can now request first if our active block is not equal to now. So we know that is one currently set up and is that is the case we want to check for whatever the direction is. In that case, we just compare with several things you can make use of a switch statement or just an if statement doesn't really matter for us. In that case, we can say if direction is equal to, let's say left. We need to put this into quote sensitise a string we wanted to compare Want this string input is going to be over here also, we need to put in two equal signs to because we compare two things. If that is the case, we want to do something. And what do we want to do is we want to call the active Tetris, don't. And now we're gonna have the set input function from one of the last videos. And now we can put in any vector we like to bring our block into direction. In this case, it's rectus three left. Don't forget that the line was a semi colon. Now we can also copy this part and do it for the other three directions. Yes, well, so if the direction is going to be right, we want to give it a vector three. Don't write. If we are giving it vectors three dot I don't know, forward. Maybe we'll want. Or in this case, you can also give it the direction up. Basically, doesn't really matter. We're gonna set this 12 forward. Yes, well, this is important. That needs to be forward because that is related to the X truths that excess. And when we are saying we wanna put it back, then we also want to bring it back over here. Well, you can also name this over here. Bang quartz up to you. Don't forget to safer script. And let's go back to unity. That's a compiler run. And once it done, make sure you select all of these. Um, your buttons activated the on click event by clicking on the plants. If you don't see this just roll downwards. Then we need to drag a game object over here. The game of Jake we're talking to is the import older because it contains the script we want to talk to. Also, we can select the function in button inputs and it's called Move. Block was a strength. Now we can put in strings based on what we have created inside the script, for example, for the X positive. This is going to be the right vector. So we're gonna set this one to be right. The axe negative, of course, is going to be the left. So we type and left over here in the Stringfield. This is that negative is going to be the back excess. So we're gonna type in back and that positive is going to be the forward excess. So we type and forward. Why once again do we do this? Because we have declared these over here, so left for the positive or the negative facts, right for the ah actual positive acts, then this one is a positive. That and this is a negative set. Don't forget to save. Don't forget to save your scene over here and let's s it out. So whenever I click on one of these buttons, you can see I can't do the movement in one or the other direction based on where want this to have? Pretty decent. So now I have a good possibility to bring my parts anywhere in the play field. It's hard to see where they currently are, but we're gonna take care of that later on. But you can see now I'm able to fill some off the bottoms over here. In the next point, we gonna go and create the same stuff for the rotation. 30. #30 Rotate Blocks UI: Welcome back to the course in this part. We want to go and ask the decree, Annie to the functionality for all the rotation buttons. In total, we have sex to do. So we go into a want button inputs and create a new function for doing the rotation. It needs to be public. Otherwise, our buttons cannot access it. As we have done with the move block, we're gonna name this, maybe rotate block. And of course, we're gonna do the same stuff over here. We put in a string and name it, maybe rotation. Now, we once again need to compare if we can do the rotation. But before we do so I want to make sure that we actually have an active block. So if active block is not equal to know, then we know we have one which we can access, and then we can go forward. Let's start with the ex rotation. You can always go into do commands anywhere, wherever you like. You don't have to do it as I do do it, however, you understand it the best. So what we want to do is if our rotation, we're gonna put in over here on rotation string equals, let's say, positive X because we named our buttons already positive X. We maybe want to Ah, do it like that. So we understand. Maybe even better if you haven't done yet. What we want to do is, whenever we do the exploitation, we want to talkto the active Tetris and set the rotation input over here. And now we can put in any vector once again any rotation vector by 90 degrees, as we already have created beforehand to any direction we want. For example, we create a new vector three open close parentheses, zero comma, zero comma zero because that's what we need to fill in. But now we see again, we are on the X position. So we need to take the X vector and bring in a 90 for example. So when we're pressing the corresponding bottom, which returns or actually has the string rotation it's going to do, they're not in the 90 degree rotation when it can. So when it not will actually be outside of the grit, since we also have a negative direction, are gonna copy this one. Rename this to N E. G X for negative X and give it a minus 90 over here. Don't forget to save and do the same stuff for the UAE ends Azad access as well. So I gonna rename this over here toe y rotation. We're gonna name this positive Why? And negative. Why? And in that case, we're gonna go in tow, keep them at 00 And over here, since it is a positive why, we're gonna add 90 and in here, Negative 90 because it's the negative rotation. Once again, paste this stuff in, we're gonna talk about those that rotation. So if positives, that is going to give us over here zero over here plus 90 a negative that is going to give us once again Excellent. Zero. And in here, we're going to put a negative 90. Don't forget to save, and that's everything for the import script. And now we just need to apply all our buttons to the script. Let the compiler run product quick by clicking inside the unity window Once again, you can always see if is running on the bottom. Right now we deactivate the move canvas for a moment. I'm gonna activate the rotation X canvas first. I maybe go in already do the changes to the button CIA as well. Like I go with Alfa to 74 or 75 and maybe gonna do some Cullerton for the press color. Something like that. It also take any other colors later on, we may go into Kobe, them all over. Maybe that is even a better toys right now. We're gonna do the other one c as well at the same time. So I don't have any differences pretty quick. So once again, I select all buttons. Hold on. Control toe single. Select them. Make sure you said all colors over here to 75. You can always see this in the scene view as well as in the game view and the highlighted. Or, in this case, the pressed color might be a somewhere over here. You can always test this out whenever you press play on that now gives all the same colors to them. I once again deactivate the move canvas and go back to the other ones at select all the buttons and at the on click event again, drag in the item holder, Select the function, rotate block with strength. So we already named them Xnegative. So we're gonna have to check this out in the Xnegative and ex positive. So for assault, this should be the negative X. So I name this one N e g acts. This one here should be pos X. So for the positive acts, same for the other ones. Once again, we need to check this anyways, so this should be the pause. Why? Make sure you're right. This 100% correct This gonna be the neck y and E g. Why? This is going to be the and e g. Is that And this should be the pos is that make sure all our correct and press play and see what's going on. First off, I want to check this. This rotation now in the X value is going toe work. Correct. Let's check the next one. The next one does not react it Only Rex from the other side, but it ranks correctly. We're going to talk about this in a second. I'm gonna restart pretty quick to check the other ones as well. So now we want to bring it to the left. Doesn't react. So I need to do this on the other side, and it seems to be the correct direction. So the lower one, this one cannot be really rotated. Well, it can. But let's test again. These directions seem to be correct. Okay, so and finally we gonna do the y rotation check. So we want to make sure we rotate this over the why It's hard to see on this buttons because we don't know if that is the real correct direction. So we may go and well, this one could even that looks correct. Ah, this one can be better seen yet. This looks rez a correct over here. So for the other side, this looks totally correct. OK, so if you have that, then we are able to do all the inputs now. And we are able to ah, put some on the ground and fill layers and stuff like that. 31. #31 2 Sided Buttons: Welcome back to the course in this part. I want to fix all buttons. As you have seen, You can only access them from one specific site. Since we have rotated them several times, you may not be able to click on them to fix these buttons. We need to select all these canvases where our buttons are laying on as you can see in the rain. Graphic right, Cast a script. There are some settings. If you open this one a bit more, you can see ignore reversed graphics. We want to deactivate that because you want to access our buttons from any rotation. So when that case, we are now able to select the buttons from any position in the game, let's test it out. So I'm gonna access this ant us from the same one from here. From here, from here and with the other one's completely as well, that's good. And now we can take care off book, building up some layers and getting rid of them whenever we have a full layer 32. #32 Switching Inputs: welcome back to the course in this part. We gonna do even more on our little button input. The point is, we cannot have. All of these are turns, all of these buttons active at the same time, we can only have move or rotation on. So what does it mean? Well, actually, we can keep on, but you need to give us or you need to create your own Ah, different designs. So the player actually is able to activate or select all corresponding buttons for that To avoid that, we can create a little button switch, which can actually indicate if we're doing only rotation or only movement to do so. We need to create this group first or actually a function for that. I'm gonna bring this down below in our button inputs. What I want to make sure is that it is a public function of type void. Since once again, we don't return anything and they're gonna name this switch inputs in here. We need to make sure who is on and who is off at what specific time to do so we can create a little bull to help us. So this bull or bull in is maybe called Move is on. That means whenever moves on everything else should be off. So I'm gonna set this one to be equal to true at the very beginning. Whenever we now call switch input, we want to switch. Move. The easiest way is we call moves on is equal toe, not moves on. In that case, we just switch from force the true or true to force, depending on whatever it is, it will always be the opposite because of the exclamation mark. So whatever move is on, it's now. Actually, said Teoh, we can do our move Canvas don't set active Toby equal to whatever move is on ISS like so as opposite. We also need to deactivate or rotation Candice's. So for each of those parentheses, game object, I just name it. See for canvas in rotation can This is and uncles Conley braces. We just say, See, don't set active Toby. Whatever not move is on ISS. So we just looked through all of them and deactivate them whenever move canvases on. Now we just need to have a button which can actually take care off the switches. Go back to unity click. It's let the compiler run pretty quick, and we can now create a button for that in an extra canvas. So go into a hierarchy. Don't select anything, right click you why? And we're going to create a new canvas. By the way, if any button is not applicable, make sure that the event system is in your seat. If you have a new canvas over here, we want to change this one from constant exercise to scale the screen size. Otherwise, we will have laid on problems. When it comes to scaling in this canvas. I want to create a new button, and this is going to be my let's say switch. You can design and create and make it wherever you want to. I gonna put it in the bottom left corner to switch later on my moat to switch that we gonna at first I need to I gonna go in re size it to maybe 75 by 75. I can go to to demote of a years Groll out Quite some did until I see the complete Candace and I again just reposition it to wherever I like to. You can also anchors this by holding down the old key and select the bottom left anchor and then drag it away from there just a bit. So that way it will always be anchored to the bottom left. No matter what kind of screen size you gonna have laid on, we can also, for the moment, put in some text something like switch. We can also do an image later on where we are also switching this a little. I can according to whatever it has been before. Now we just need to connect. Our switch was a button click to our input holder. So we just select the plants of a year, tow her neighbor on click Dragon Input holder, go to button inputs and go to switch inputs. So whenever we are now clicking on that, we're gonna switch the inputs. Let's test it out as again see, currently everything is active. But when I switch, it starts to do the switch. So in that case, we need to make sure that our move canvas in start is going to be whatever it has to be same for the other rotation campuses. We can also do this in awake, so basically it doesn't really matter. Let's do it and start. Because just to avoid any problems we may encounter and start, we can call an extra function to simply file a process a bit. So basically, we could do the same as we do and switch inputs, but we do not switch the actual input. So what we can do is we can set the inputs. I gonna copy this complete part over here, name this one set inputs. And what I know I can do is I can get rid off this function or off this bull check or a bull switch. So and start we can call set inputs. It does not need to be public, it's just a time point and then here we can get rid of that. But when we do this bull tank, we want to set the inputs afterwards like that. Also, we cannot take the same functionality and bring this into the start message. So we're going to send to the inputs. But we do not do the switch as we do in switch inputs. Don't forget to save, and when we start now, we're gonna set the move automatically to be active And when we switch, gonna have rotate in the active one. So now I can switch back and forth between those modes. 33. #33 Speed Up Button: Welcome back to the course. In this point, I want to create another button which is giving us the possibility to speed our blocks downwards and two things we just need to take in consideration. At first, we're gonna need to open our button inputs and create a functionality for that. First off, it needs to be a probably time point. Otherwise, we cannot excesses from a button. We can name it something like set high speed. And we just need to make sure that we access our Tetris block speed as Agencia. More full time is almost beat, which is going to be the force time forced downwards once a second. If you want to change that, we can actually go into and create an extra function to excess that to do So we're gonna create another public Boyd and we got on the name, this one something like set speed. We don't need to any arguments over here. We just need to call this function. So what you want to do is we don't wanna ask the excess full time to be equal toe arrest. A small number 0.21 was, or maybe 01 that will make sure that every on tense off the second the block is going to fall down until he reaches the ground. If that is too small or too big, you can change these values, whatever and whenever you need, don't forget to safe tendrils block and go back to buttons input. And here we just want to make sure that we are calling the Tetris block or, in this case, active Tetris Don't set speed and that's it. What we need to do now we just need to create a button to set the high speed from. We can actually take this a switch button and duplicated Let the compiler run before you do anything else. Otherwise, it will not let you duplicate that and bring this wherever you liked it, for example above it. Or maybe you like to see this on the other side off the game view. So you can also go here ankle This does a bottom right and drag it up until it fits your needs. Maybe something like that. Now you can also change the text or just get rid of the text is completely up to you. You can ah do something like speed or speed up. Or if you're gonna put in any image, for example, this works 1% as well. For now we can give it a speed up. And in that case, I got not doing Ah, you I image and bring this over here. I'm gonna hold down as a shift key and reduce it a bit. Maybe you're gonna bring this over there. You can also take the text and maybe bring this up over here. So it is on the bottle on the top and in the small image, I can bring in one off my arrows, for example. This one I can tent it to any color. Maybe black and I can also go and rotated by 90 degrees. If you don't like black, of course, take any other one. So now we just need to make sure we re name this one to be speed up or speed down basically does matter. Go to this switch, inputs button input and go to set high speed and some acted. So whenever we press play now and we click on this button, the buttons or the little blocks will fall down quicker. Once again, you can do anything. Was that button and was the speed However you like Teoh 34. #34 Delete Layer Check Full Layer: welcome back to the course. This part we want to start to work on how we can a delete actual layers whenever there fall was blocks. So to do so. Of course, we need to check our grid if there's something inside or even if everything on one specific height in the UAE, access is completely full. To do so, we need to create several functions in side our player feel or playfield script. So open your playfield and in here and the very first, Lauren, any line we're gonna create and function which we can excess from our Tetris block. In that case, it is a public void and I'm gonna name this delete layer. Actually, that does not directly delete the layer. But it's our access a point once again from the Tetris block, you may remember in our update loop, wherever we are falling down over here, we also have a command already which say's delete layer of possible. So if we have or we will save the player or play field at the moment and go over there, we can just say playfield, don't delete layer. But we off course need to call the incense first So I field, for instance, the lead player. Don't forget to save Tetris script or Tetris Block and go back to play field. Now we're gonna need to attack wits. Astle, there, we want to check to do so. We're gonna loop through all. Why? Well, use over here. So I name the end. Why is equal to zero? And our Max is going to be a group size. Why? So meanwhile, why is smaller than our maximum great size? We gonna loop through all wise now? First, I gotta do some commands. We need to check each layer we're currently in. So I gonna create a new function for that Check full layer. Then we're gonna have another one which is going to do, If that is the case, we want toe the lead some blocks and finally we wanna move or down by one. So this is what we're gonna do from our delete layer function. First off, let's tack for full layer to check this once again. We just think I'm the we just take why as an indicator and loops reacts and that if it returns true, then of course we gonna have ah, full layer If it returns false, then we don't have that. And we don't continue in this axle. It's oration. So in that case, we create a bull this bull of once again Just give us back true or false. So we gonna name this check full layer. We're gonna need to have an indicator off an integer. And I call this why? Because the others when we actually need to put in. So what we do is we call Jack full layer from here with the correct or the current. Why will you? That's where we pass it in. Here and now. We looked through accident set so int x and while and acts a smaller than our grid size axe , we're gonna go into the next situation forces that value so into that grit size that so we looked through that as indicators for the correct size. Now we checked the grit if the grit, X comma, why commas at is not equal. So no, or in this case, we can say is equal to know. So if nothing is inside, we want to return force because this is not a full layer. If we do not pass at this test or if we pass this task completely at the very end, we want to make sure that will return. Throw because that means whenever we pass this test for this particular layer we're currently looping through, then we know that we can reduce the snail. Now. We just need to go into the delete layer, function once again and check the actual boot full layer. So we request. If open close parentheses, check full layer. So if that returns through often close, Prentice's behind that. Since it's called like a function, then we want to do the delete. Enter blue move block stuff inside or a non takers. Of course, we need to put in why, as an argument, otherwise, check full Layer does not know which layer it has to check at the moment. 35. #35 Delete Layer Deleting Blocks: Welcome back to the course in this part. We want to continue on working our delete layer function. That's open our playfield script. Where we actually already attacked in full full layers, like inside the delete layer function we know want to create is the lead. The blocks, like all blocks in the layer. To do so, we create a new function for that which is helping us to look through everything based on the y input again. So I'm gonna need to name this, of course. Maybe delete layer at. And the answer just means at the Inter. Gia. Why So whatever the layer is, we're gonna pass in over a year. This is going to give us the possibility to only delete everything which is currently on. Why we don't need to do is of course, we need to lose through accent that and takes the Y coordinate off course and consideration based on the input or the argument Well, over here to do so. Once again, we created to four loops, two nested for loops, double tap once again. Great size X is going to be our maximum indicate over here. Then we type for again double tap for that which is going to represent a Margaret size Zad over here. And in the very end, we want to make sure that we destroy objects and these objects are sitting in the grid in square brackets X Come on. Why commas that? And now we need to a put after the second when we need to say, Don't game, object and close the line. Was this in my coat on? Once we have deleted the core game object, we need to reset the cell, which we asked Lee Freed, Where is the actual game object? In that case, we gonna say zig grit in square brackets X comma Wycombe A set it's equal to know. So it's empty on once again on what can be refilled at all. We just call this function delete layer at why, and don't forget to save the script. 36. #36 Delete Layer Move All Down: welcome back to the course in this part. We want to make sure that we create the functionality to move all the layer down. Whenever we have created a full layer, open your player or apply field script, and we can put the sum here like where the delete layers at. We need to put this into our delete their function, which we're going to call later on. Whenever we are done with placing one off our actual Tetris blocks, we're gonna create two functions which are taking care of all that stuff. First off, we want to call a function. Which is it reading through all wise, like on why Indicators. So in that case, it's going to be a void. Move or layer don't something like that. And as an indicator, we're gonna go and take the Inter gen y once again. So we're gonna have to pass it that in from this position, basically, So wherever we are, we going to start at this point, we don't need to go through all we only want to make sure that whenever we have a full layer, we're gonna start at this as an indicator to do that. We're gonna need to create a fall up and look through the rest off the existing. Why Nair's to do so? We create a for loop we started into Joe. I we for now, Name it or grit size. Why? Over here and the maximum. But now we need to do something special. Instead of starting at zero over here as zero I as an argument, we gonna start at Why so the why which is coming in over here, which we gonna pass over so and now we create a second function which is doing all this movement down once for us. So I gonna create this pretty quick first. So it is another white move, one layer down. And, of course, as an indicator, we're gonna put an Inter Gia off. Why? Once again in here. So what we're gonna do over years we loops Rex and that once again and do this layer wise based on this, why which we're going to pass over from here? To do so, we create once again a full loop with indicator X and its great size x as a maximum. Same for the that value as a group size Zandt as maximum over here. So now we gonna have to update our grid. First off, we need to check if it is No. So if the grid in square records X comma Wycombe a set is not equal to know. Otherwise we will get a narrow like another reference exception was something Simula, If that is the case, so is this something at this particular point, we want to move it downwards. So first off, we need to update the grit. In that case, we gonna take why and negate this by one and start over there to copy it to the next layer . So we're gonna say X comma. Why commas that? But why in this case needs to be once again negated by one. And then we said this would be equal to the current grit. Basically. So X comma, why come? Is that so? We could be everything from this position. Two in the gated won't buy one position. So we drop it down Morts. Then we need to make sure that we override this by now. So we say the grid and square brackets X comma Wycombe Azad is equal to know. So we empty that spot And of course, we need to update the position now off the axle grid or the pieces which are inside the grits. A report. We reposition the actual game objects based on the transform. So they say the grid X comma y com Azad we need to once again knee Gade. Why? By minus one and we said its positions. Once again, we have transforms. Start inside from all the small cubes and we add vectors. Three. Don't down to the current position down once again represents one or minus one. In this case, at a negative, you could also say in negate by vectors, reader up basically doesn't matter so and finally we just call move one day it down. So whatever the current indexes from here from our move all layer down. So in that case, we say move one day out, layer down by why Essendon Next indicator. Now we just need to make sure that we call move or layer down wizened over delete layer function. So move all layer down, open close parentheses, and we put in the why as to coordinate. Don't forget to say it's a script, and now we're basically done with the layer check or the D late layer 37. #37 Delete Layer Bugfixes: welcome back to the course in the last ports. We were actually creating the delete layer functionality in this part. I want to make sure that all of that stuff works. So to simplify the process, we can go to the PIF toe the playfield, and we're going to get rid of some of these blocks and just keep our a block. I'm going to reduce the size of elements to be one in the block list, go to pre fabs and dragon the old block over here. Since we cannot actually Fillol these blocks was old blocks. We need to a reduce the size of the playfield and get rid off t block first. So I'm gonna get rid off the tee blanc, bring in an old block. I gonna go to three d view so I can't see stuff. Better to double click it or when I double click it. I can as zoom in and I bring this over my playfield snapped and at the correct position. And bring this up slide a bit over here so it can drop. We can also drop it already and one off these corners basically doesn't really matter. We just want to safe or we want to check if everything works. Also, since my game, prayer may not fit all these blocks because there are five instead of four before we can increase the playful for a second for to be a four by four. So we go toe Blakefield and change it here to four by four. So have a small of playfield and still everything should work. Now when we press play and we only get, oh, blocks down from the list, we just need to move them around and can see if we are able to lead to lead or the layers. I'm gonna wait until everything is down over here. You can off course go into the speed up of here was our speed a button speeded up and boom , as you have seen, all these two layers completely has been erased from the point off actual delicious. So now we know that our layers are going to be come deleted correctly, and everything else is dropping, which is not correctly or actually not fulfilled. Once again, you can do several different tests. For example, we can speed this a bit up. I can bring to on top. So we see that only these which are being left at the very last are still going to be existent inside our game. I'm gonna speed this up. These ones got dropped, but this one did not drop. Overall, I just noticed that I have a little type over here in two or inside of a move. All layer down function when I currently do is I tank. Why, as an indicator for moving the layer down, But currently we're looping through I So it is important that we gonna pass in I instead of why. So that would fit the problem that the drops are not working correctly to do the test. Once again, we can open oil, just go in play mode, drop all down, putting several onto each other so we can see that this is going to be 1% Lee working going into the last one. And now it doesn't even bring it away. Since not all layers are goingto be affected. Whenever we start from the bottom and go up to the top then and we gonna delete one of these layers and the other ones are popping down than the lowest layer is not going to be rechecked. To avoid that, we gonna have to do a reversed for Luke Check. What does it mean is we're gonna start at the very top off the playing field and go downwards from there. Whenever we find an empty one, we're gonna update them, move everything down and go forward until we hit the ground. That will avoid that. We have a problem that all these layers are going to be ignored. In that case, we just take this zero away over here and said Why? To be equal to the grid size in this case. Why? And here we just need to make sure that mean why. Why is big o equal to zero? Then we need gate. Why? Inside theater vacation? We need to reduce grit size. Why? By one. So I'm gonna do this already. So we gonna say once again in this delete lying a function which we're calling for Mama. Tetris Block. We go from bottom, we got do not go from bottom to top, but we go from top to bottom. We sent why to this size check until it is hitting the zero area like the bottom layer. And before that is going to happen, we've been use Why? So we go once again, back warts. Don't forget to say the script and that's test again. This shouldn't know once again started to check each layer from the top. Like over here. We reduced it by one because the full size of the here may not match our axle grid, which will not grew, actually fit our group because the great it's one smaller than our great height. So in that case, we start here and check through any layer. Let's assume this one has a full layer over here. What will happen is that ever seeing a buff is going to be updated like it's going downwards. And then, since we have been here already, we do know check this anymore the other way around us. Whenever we're starting at the very bottom and this bottom layer is full, then we drop everything down. But we have checked this layer already, and we start to go in the next layer. This one, even if this is also full, would be ignored as it has been before. Don't forget to save everything, and that's test again So I bring all of these down and gonna try to make one looking over here both So you can also put even more above that she liked. They're not gonna go and four full. The bottom layer, it's on the bottom two layers. So once this is going to happen, both assured work both does should drop. And we should only have this one left over here once again. This is because otherwise at the bottom layer would be ignored because it has been checked before already. So that's why we go and start from the top check from the top and then moved downwards from that point. So we will not ignore the bottom layer anymore. That's the trick. You We can make use off here to delete or actual found layers without any problems. 38. #38 CleanUp Random Start Block: Welcome back to the course in this part. I want to go back where we actually start at meaning. I want to do a cleanup. And I want Teoh give the first block automatically as well. So we don't necessarily have to be or have to get one already at start to do so. And first I got to get rid off this. Oh, Block. Also, I go back to my playfield and change back the size 2585 So we have a bit more space once again, also in the playing field. I want to add all the other blocks again as well. So I took Make this a block list zero size. I want to make sure that I will lock the selection. And the inspector was a little lock symbol. Select all my blocks over here and to drag them into the block list. So everybody is back where it came from. Now you can get rid of the lock symbol again. And so this way we are already wherever we have started. Now when we want to do is that will automate the first or randomize the first bloke already as well. At start To do that, we're gonna have to open on Playfield and go into a West start message. And here, after we're done with initializing the grit, we want to spawn a new object or new block. So we just call Spawn your block. And that's everything we need to dio to automate the 1st 1 which is off course at the moment, completely randomised. And whenever we are starting the game right now, we should spawn the first block. And as you can see, it just took any of these blocks were able to place them wherever we like to. And of course, the game is running over and over until we're losing. We don't have losing yet, but that is part off another video way later on. 39. #39 Ghost Block Prefabs: welcome back to the course in the next upcoming parts. I want to create ghost blocks. Those goals blocks are just a representation off where our actual active look is going to land So the player can see that easy and where his block is going to land, in which direction, rotation and stuff like that is going to happen. And if he is hitting the correct spot, he wants to go in to do that. The first thing I want to do is I want to create a new material for our ghost material. You can name it ghost material or just goes whatever you'll please. And like, maybe I just name mine ghost. I want to give it a special color. Maybe something oranges, or maybe whatever color fits your axle needs, maybe something we don't have at the moment. Also, I want to make sure that this is going to be a transparent rendering mode. You can choose between all the standard changes or any other Seder you prefer. And what do you want to do is you want to go into the Alfa Channel off that and reduce its light some bit? Maybe, toe, Um, maybe it's to 50% of something about around 230 maybe more, maybe less. Depends later on how good we see stuff. Also, you can play around with all the other sink of your leak. Needn't like. So what we're gonna do with this material, Maybe I gonna give it a bit more smoothness of here. So it's a bit more bright, however, Was that little material we're gonna create our goals blocks right now. These girls blocks are also prefab. So basically, we need to duplicate all of these blocks and make them ghost blocks so you can select them all and hit control D. It's going to take quite some time until they all copied correctly. Now what you want to do is thes copied ones currently for me they are selected to they all have a one behind them. I want to drag him all into my list of the or into my scene. But I also want to do is I want toe actually open all of these and give them the ghost material. I want to select all the cubes first. If you don't like the processes, I do it like select them get all you can also type in the name off the whatever the object issue want to select over here like you can type it over there in the search and just type in Cuba, for example. And all the cubes will be highlighted which are currently represented The scene so you can select that easier. Gonna give you how I can or here you can do this. You just type and cube and I can see all the cubes currently are visible and highlighted. And now you can just select the first and the last by holding down shift and all of the cubes on Also liked it once again all up to you However you want to manage sad. What I want to do is I want to take the ghost material now and drag this in the inspector. So all of these are no ghost materials s I can see whenever you get rid of the search, everything is colored correctly again. If you once again anyhow do not like the color And how does it look and so on? It's a force. You can always play around with a different settings, different materials. Maybe you can also highlight this even more. But since these are kind of flat, sir faces, the reflections are not quite too good over there if you want to. These reflections is also totally up to you. You can even make them a bit more dull over here again. Get rid off the smoothness completely. You can make whatever you please and like, but do not go with metal nous. That doesn't make sense over here. Once again, you want to make it so that the players sees easy hum where these things are going to land , like where all these blocks are going to land. So that's where the color council place. If you don't like a purple or you don't like orange, you can make use off any other color, which is goodly or good seen and probably is not a color you have already like, if you would go with a such a blue one over here, then you might want to take this blue and make it a bit darker. So ah, the player doesn't know how to get confused by these colors. So once again, all of that totally up to you. You can set this up however you like you can make it even more transparent. Also depends on what kind of background color you have and so on and so force keep all of that completely in mind. Now, since we are done with all these ghosts, we need to update these pre fabs. According Teoh newer versions, like in two K 19. You need to open these and apply the changes like by overriding I hear in Unity 18 or to K 18 I just need to go and click on the apply button over there to apply all the changes I have made to that Once I have applied everything like the material change in, I can do really delete them it in my prefects whether I gonna have all of these. So you can once again go over here if you like Teoh and renamed them accordingly Inside, over here or here And the inspector basically doesn't matter. The inspector does not care about this where we need to refresh this night on. Well, nope. So it is totally important that you do the change directly on the prefab then because the prefect name once again that case did not get or got over written. So I just updates pretty quickly. Was hitting f to And you're just passing over the name off the ghost like I still have that in my copy paste so I can just paste the name over here and now I have renamed them or to be ghost, but not block. Good. So what we now can do is we can actually Instead, she ate them wherever we want them. And then we need to manipulate them so that they are automatically falling down for us and checking where they can actually land. And where is the sport? This ghost, or actually is the stone we're currently playing is fitting in. 40. #40 Ghost Block Ghost List: Welcome back to the course in this part. We gonna add all of our goals, blocks toe on Playfield script and try to instance he eighth. Um, meaning whenever we insensate a c block. We also want to incense. She ate a sea ghost. How do we do this? At first, we open our Playfield script and create a new game object array, but not block list, but ghost list. So I just copy this one over here, bring it down below and rename it to ghost list. Whenever we safe and go back to unity, we should be able to drag in all sea goes all ghosts we gonna have over there. I can see you as the ghost list. And now the important part is going to happen. We need to make sure that all of this order over here like C i a L O S t is the same order as and ghost list. The most easiest point probably is. Just select the little lock symbol over there. Then we're gonna select all these ghosts in order. And since we still have the see in front or this letters in front Well, hopefully you do as Well, then we can just simply drank them into the ghost list. So in that case, we cannot compare C block and see ghosts are at element zero and all the other one's a c i a l o s t c i a l o s t are going to be represented and connected to the correct ID's. This is absolutely important. You can, ah, again check the unlock symbol of this a lock symbol toe. Unlock the selection, and so we can now go forward. Don't forget to save your scene and go back to our place, script or Playfield script. Whenever we spawn a new block off course, we want to spawn a ghost. I already had a command over there. So what we want to do is we want to spawn a ghost at the same time. This resin, simple and basically is the same as we have done over here. We just need to make sure that the spawn point and everything else is corresponding to the spawn point over here. So what we can do? Is we insanity? A Just a new block, like a ghost block. I just copy the complete line over here copy and brings us down below. I want to rename this one to be new ghost because we need to access to us in a bit. What we know want to insensate is not from block list, but from ghost dist Random index. So we take the same calculated random index and bring it to the spawn Point Saw the new block. And the new ghost will be at the same position whenever there spawned at the same rotation whenever they respond and so on. And so force. Now we can get rid off the set in port part over here because we have done this directly in the tatters blocks. Everything else for the moment will stay the same. After that, we need to create a connection to our axle. Your block. We're currently talking to buy a referencing the new block. But that's what we're gonna do in the next video. Don't forget to save and see on the next part 41. #41 Ghost Block Reposition: welcome back to the course in this part. We want to start to work on our goals block script. The Ghost Block script will be sitting on or every ghost block and has to follow the usual or that currently active block, as well as mimic its rotation and position. But also, we wanted to fall down completely and test where it can land on and where, not based on the grid. To do so, we're gonna first off go to scripts for the right link ready New Sea Shell script and named this ghost block Whatever you please tonight and opens this one. I've been mono develop or visual studio or any other I D. Once it has been loaded and it's open, we gonna need to have a connection to our current parent object or basically the the actual block the player is currently using. So I'm gonna actually create a new reference to that name, it game object or the type of game object, and this is going to be the parent. Basically, it's not directly apparent. It's just someone who we want to mimic with Ghost Block. Also, we wanna have a connection to the Tetris block, which is sitting on that so we can manipulate or request things if we need to. So I'm gonna name this may be apparent Tetris or something like that. Now what we want to do us, we want to reposition in each step or whenever we want to. Like we can do this. An update. We can do this in a court. Protein doesn't really matter at all. We want to reposition our block based on the parent block. Once again, we can make use of a nine AM aerator or called core routine, or we can put it an update. That's pretty cool routine. So you see what's the difference? The core routine is going to be nothing else. In a time based action function we can put in ports Is and Wild loops and several other things which are taking care of timing internally. Also, this is going to be like no directly running an update. It's like a process next to update, so usually this has taken whenever you want to save some CPU time and stuff like that. This I am aerator or core routine. I gonna name this reposition block as again. See, it's built like a like a normal function. That horse also has the parentheses behind it. We can also put in any arguments, but we don't need to. When we are running this particular co routine, we can create a while loop and test stuff out. First off, we want to make sure that our parent Tetris, as a little typo if our parents Tetris is unable to then we want to do stuff. So if parent Tetris thought enabled so the script Tetris block, whichever we're currently referencing, is enabled. Then we want to reposition this Brock, how do we do this? This rez a simple We can easily create a small function Or do this or that stuff over here . Resume easy to reposition that. Let me product quick, create a position function so white position, position, ghost or something like that because probably later on, we need to excess us from any other point as well. So while we are running this wild loop So while we are only having an urn able parent Tetris, we want to set transformed. The position is equal toe apparent that transformed our position. So the game object off our actual block we're playing Same for the rotation we want to set . Transformed old rotation is going to be equal to our parents. Rotations apparent. Don't transform, Don't rotation. Now we want to call this position ghost function while we are inside the core routine. So we just real actually call position Ghost Open goes Brian Disease and close the line was Sister Michaela. Now the next step is we want to move downwards. So to test if we find a solid way or any position where our block can be passing in. So the player sees this particular movement as a helper after we're done was moving down. Once we wanna say when a yield return you and now we can wait for a couple of seconds. In this case addressed there is a small number something like 0.1 if you can even go. But how a smaller with this number like 0.5 or something similar. But we don't do this like 60 times of seconds, which is what the update? Lupus. So that's where we save some CPU time of their Whenever we are leaving this complete why look because of apparent Tetris is not available anymore. Then we can just destroy the ghost. So destroy open, close parentheses. Game O J. So whatever this is going to be here and just in case, even if we probably don't need to, we can say yield return? No, like that. Now we just need to kid create the function to move downwards our ghost. 42. #42 Ghost Block Move Down: Welcome back to the course in this part. We want to continue on. Our goals belong script. What I want to do is they want to start to work on the move downwards function. There will be some things we actually already did inside the Tetris block. But we will do this year a bit faster than in Tetris block. So first off, we're gonna create our move down function. So it's of type void move down and we call the moved on function. Of course, every time we are inside the wild up over here, what we want to do in this ISS. At first we want to take while we have a valid move. But since we don't have access to any develop move checks, we need to create a new one. So I'm gonna name it once again, check Val it move open goes parentheses. We don't have this function yet, but we were created right now and you probably know what's coming. Actually, everything inside the Tetris block a bone to the checking move over here. The Vela Tech move is going to be copied at the first place. We need to do some changes to that. But for the moment, keep that and copy this completely. The complete bull tank from Tetris Block. Go back to do here. Maybe I just go into this and paste it over there. So we have a Jack Vela move. Also incite a war ghost. We no need to do us. We want to do the same over here. First off, we need to tank is our child is going to be inside the grit. And if that is the case, then we go forward and check for each element in this our child to get its proper transform on the great position. First off, we're gonna do the same tank about the parents transform. So if we have actually found a transform which is actually not equal to now and is not the same as we are we going to return false. But before we do that, we want to do another check. This Jack is going to be if he is not equal to know as well. And now who want to request t's apparent? So that transforms parent is that is equal to ourselves. So apparent. Don't transform. I never want to return. True because we want to ignore this particular part over here, so we get a valid return. True. So we get a valid position, so we do not actually stumble upon ourselves. So once again, if we stumble upon ourselves, we say Okay, no problem. That's we We have a valid movement over here and that's everything for the Czech village. Move at the moment. So now whenever we have a chunk of l. A or valid move over here, we want to move down Warts. How do we do this? We say transform the opposition plus equal Vector three down. And what we also want to do is when we do not have any Vela check anymore, we want to move backwards in the up direction so we can just create another simple if statement, if not junk Vela, move open goes parentheses. We said our transform the position plus equal vector Sri, Shut up! And now we should have a working ghost. We no need to do us. We need to set all the parent objects and the Paris parent Tetris whenever we create aid. An instance off the ghost 43. #43 Ghost Block Final Steps: Welcome back to the course in this part. We want to finalize our go script was all it's necessary Data. First off to run the co routine, we need to start it. So in start, we're gonna say, start co routine, open, close parentheses and which one is the one we want to call its reposition block. So we gonna pose it over here, close parentheses and close the line was the same. Michael, this is how we start any code routines. Now we're gonna have to create an excessive function for our ghost where we can pass in the parent and the parent Tetris. Since we are accessing those from the playfield, we gonna have to reference them from there as well. First off, we need to create a new public void set parent function, and we can pass in now the actual game object. We are actually setting game object. I gonna name it. Underscore, parent. So you don't get confused because we're not talking toe any parent of A or we don't have something like parent parent over there, so we know and the script also know. Okay, we're gonna set this parent to be this parent with the under school over there. Speaking off that we're gonna say Parent is equal to underscore parent, so we don't have any confusion later on. So we set once again this parent to be despairing, Whatever we're setting over there also, we want to get the component of Tetris block from our parent to pass it into the Tetris block over there. In that case, we can say parent Tetris is equal to parent Don't get component. And now we need to pass and the type Tetris block open close practices behind the trying of break it's and then a semicolon toe the line. So now we have also a reference to his apparent Tetris. In that case, we can now check in our repositioning if the parent Tetris is still enabled. Whenever we are referencing that, don't forget to say the Ghost Block script and let's go back to apply Field and Playfield wherever we are currently in san, she ating a new ghost. We no need to set its parent, which is currently the new bloke over here. To do that, we just need to call the function inside the ghost block. So first off, we need to could get the connection to the girls block script. So what we're gonna do is we say, new ghost. So this the game object we access. Now we get its component open, closed, trying a break. It's off type, and we need to pass in ghost block because that's where the function is. We want to call, which is called set parent. We just created beforehand, and we now need to pass in the parent object we want to parent. In this case, it's the new block. I always say you block over here and close the line was a semi colon. Don't forget to save. And now let's go back to unity and see if we have any problems or compile aeration, Eros or anything else. Even those warnings should go away. That looks good. Now we just want to see how our game with all these ghosts are going toe work, press play. As you can see, we get another reference exception, and also my wire loop is going to stuck over here. We get this no reference exception because all our ghost blocks do not have the correct script attached. As you can see, it has the wrong script. In that case, Tetris block, the best way is we gonna select them all. All goes blocks. Make sure all six or however how much you have are selected, President the little JIA and remove this component. You might want to keep the sun action by once again making use of the little lock symbol. Go to scripts and drag goes block onto them because that's what they are. Unlock this selection symbol over here and test again. Now you can see that the girls block is directly under. I will block whatever a block of this. Then we can also see if that would match and you can see also, it would no show you where this block is going to land. So the player now can see better whenever he rotates as well, where this block is going to land and if it is possible to put it anywhere in between or something like that. That's important, I guess, for a better or more fluid gameplay. And now we can ask the yeah, play the game quite nicely 44. #44 UI Intro: welcome back to the course in this part. I just want to explain you what we're going to do next. What I want to implement is any house, um, score some counter, how many layers we have, actually, year deleted or just fulfilled and win while gaming as well as I want to create some kind of a preview like what is going to be the next block into our game? The problem was, the preview of the 1st 1 is we gonna need to position somewhere over here. I'm gonna paint in over here so you can probably get an idea about what we're talking about . What I'm talking about. Let's assume we're gonna get a long peas later on over here. We want to show this. The problem is that we are completely 3 60 degrees in or playing field. And we cannot just a take a three d object and place it anywhere in the scene because the camera, which is going to rotate the world time around on a play field, may or may not see this. Instead of that, I would create what is called a rule image inside our you I so in our base canvas and produce it so that for example, over here, the object is going to be spawned. Also, I need a secondary camera which is looking from this point on to this object and then actually reflects what it sees. So the camera reflects was it sees and actually bring this onto the raw image. The point over here is also once again, this camera, when we would be with the camera at this position and look to the Playfield, we probably see this object. What we need to do is to not see we need to track the camera or we're gonna need to put somehow a wall in between the side of line. But the distance to this camera need to be high enough so it cannot like a sticks rule or will be behind it. So that's how I would go and create some kind of a prevue object over there. We're going to do the calculations just by random, as we have done before. We send it some kind off a prevue manager anyhow, and then the Prevue manager creates that object, like from code, and then we probably rotate this so we get a bit off a rotational feeling and three d feeling over here. Maybe we also put some kind of a frame around it. So it's not looking too shabby over there, how all of that is going to be done and how we would produce that will be explained in one of the next videos or in a couple of videos. Also, what I want to implement some score, for example. We're gonna have a score over here like based on home Any layoffs we have created, for example, per layer. Like when we delete one, we probably get 400 points when we gonna clear, Like to we probably double that. We need clear three. We double that again. And maybe when we clear four in total, we gonna double that again? Something Simula to this also, we might want to increase the overall speed according to home. Any score we have, which means of the specific score can maybe bring us to another level. So we can probably also do something like what is our current level? And based on the level, we gonna increase the four speed of the here plus something per level, plus maybe 0.5 or in this case, a minus 0.5. Also, we want to see how many layers we gonna have destroyed beforehand. So we maybe can also determine the level based on these layers. For example, if we have cleared four layers and total, we're gonna increment level plus one, all of that is possible, and we're gonna have a lot of other possibilities to input on that stuff. Also, for the score, for the level in the layers, we want to seek out some points or some positions where we want to show that. Begin to this probably directly under our prove your window. We can also, since we have enough space on the other side, put it over there. If you're going to lay down, have this game on a landscape mode like this one, then we have enough space. If we, for example, would think about it when we do not have the landscape but maybe a portray mode where this window is a bit smaller, we might need to go out away, but with our main camera from the playfield. So we have enough space here over on the top four, for example, the new Prevue as well as put the score the level and s well, these layers and stuff like that in the top. And these buttons would automatically go inside these corners over here. Once again. These are designed decisions later on. You gonna have to make on your own. I just wanted to let you know what I am to do in the next coming videos, and I hope you get the idea about it. 45. #45 UI Previewer Setup: Welcome back to the course in this part. We want to start to create everything for the Prevue. As I explained in the last video, I go 12 places somewhere here. You can also once again put this in the center of the playfield. Once again, a design decision to you for stuff to create this. Priv, your we're gonna have to goto our current can with were or switch inputs and stuff like that are going to be related to write like you I and create a raw image. This is necessary. We need that. What we want to do is of course, you want to place this anywhere so we can go to to demote scroll out quite some bits. So we see our complete canvas. Maybe bring this in the top right corner. As I explained, how big you want us to be is once again absolutely up to you. I gotta maybe make this 11 50 by 1 50 Gonna bring this over here anyhow. Over there once again. What? We now want to do it. Want to produce or showcase the next tile or the next block to do that? I would at first go once again closer to my playfield and see where my camera at the moment . ISS I want to leave some space of a year and probably put my priv viewer anywhere over here . To do that, we need to several new things that for us this role image needs the texture. So we go to our taxes folder, right click, create, render texture. This run, the texture is going to be our prevue. We don't need to go and change anything over there. We keep it as is and we keep it as two ds. Well, we can later on going to check these other settings out. But for the moment, just don't touch them. What you don't want to do is you want to bring this preview image onto the raw image like this in this tanks airfield. Once again, we don't touch anything. What do you want to disable is probably right. Cast target because we don't want to target this image. Anyhow, the next one is to see our image. Once again, we're gonna need to go and bring a camera into play. This camera will be connected to this prevue texture. Let me show you what? I mean, we gonna create a new right click. You I camera. As you can see, this camera is no created in two D space Just because I have it over here, or so it still is perspective. I'm gonna bring this, like, over the to the right. When I go out of to demote, it sits somewhere in the space. Now, once again, they're gonna zero this one out quite a bit. And maybe I bring this a bit back so I can see something, at least over here for a preview. Also again. See, the background has no change for this camera because this is the current active camera. When we know want to do is tow. Activate this preview a part. Once again, we need to make sure that this prevue texture is connected into the target texture over here. So we're gonna drag that into this camera. So now we gonna see everything inside this little preview window. When we now can do us, we can drag this anywhere where we don't see this anymore. Just do this on the X axis and do it far away or away. Enough. If we would know take one of our prefab, for example. Maybe this one. And bring this next or in front off this camera, like on the 00 access. Maybe we're gonna bring the camera it bit up. We're gonna see the Prevue off the next upcoming block. Also, once again, we still have this prevue. I'm gonna deactivate this Tetris block and press plane. Show you now what's going to happen when we know would play the game and rotate? You can see over here in the background. You still see this piece. But that's what we want to avoid because we don't want the player to see what's going to come next. When he just rotates the camera, we only want him to see that whenever this is inside this image to avoid that, we're gonna go into our materials for the and created new under two material. So we go to Seder Standard under it color, and we color this to whatever our background color is over here. So in my case, black for the moment now, I'm gonna go into my scene and create a new three D object quant. I want to make sure to rotate us by 90 degrees to here and scale it up quite some bit. The actual size does not really matter, but the position does what I mean by that. Now, whenever we rotate now, we want to make sure that I want camera whenever we do. This rotation is not sticking through this quote. So this is our hiding image, which is taking care off that that's Karen does not see this block. So if it is too close for you, you can always bring this next to hear or even more once again, does not matter. Make sure that the camera is not rotated here or not, even anyhow intersecting with our playfield. Also, this camera will not see anything on the court because the court from the backside, as was planes is completely transparent. This is pretty good. So now we take on new material are gonna name this may be hidden or hiding or whatever material and bring this on to my quarters. So now it's not white, but black. Also, we don't want this to cast shadows or even receive shadows, and we press play again whenever we are now rotating on a camera inside the game, we don't see anything. Throw this block. Can see our cameras over here. We don't see any shadows from that as well as we do not see this little object behind this block. This is absolutely important for here. So now it's since we have this hidden object or this Haider are gonna rename them too, or this one to Haider as well. And now I can't take this camera and change its background to any color again, as I like. For example, we can go from away from skybox, give it a solid color. And in that Kayla, or in this case, it just represents the blank color over here. So no matter what kind of color I'm going to shoes, he can see nothing is changing because it's taking everything back from the vein camera. Pretty decent. And now we just need to decide how we want to incent e eight or create all these pre five blocks so we can showcase them over here and also on the image. We probably want to create a frame around it to visualize that even better to do this visualization, we can, for example, take the grip material and bring this on an empty emit or any image and make it invisible, or we gonna go and create a very own. I have a frame and a frame mask created already. So if you like to, you can make use of them. I'm gonna drank those inside my field over here can see this frame has rounded corners or the strain mask. And this rain has rounded corners of here as well. So if you like to make an image or in them a train around our camera image over there, we can just overlay it. So our role image currently shows whatever the camera sees I would want to do is create an other image over here and bring our frame over that. But we need to make sure that this is a sprite two D u. I apply the changes. Same for the frame mask Sprite. To do I apply the changes to the mask on this image we're gonna bring now our sprite frame . As you can see, this image is too small because of a raw images 1 50 but this one is only 100. We're gonna have to make sure at least to bring this to 1 50 by 1 50 s. Well, so you can also rename this one to frame. And the causing now already also is we can now tend to this rain, for example. We can make it red, green, blue or whatever we please in. Like I'm gonna make my frame white again. Once again, you can decide how you want to handle this on your own. And then we're good to go, at least with the Prevue or the part off the purview set up for the moment. 46. #46 UI Coding Previewer: welcome back to the course in this part. I want to create a spawn, er object for our previews of here. Also later on, we need to think about how we wanted to manage these blocks differently. Or if you want to do that or even not. Basically, what we need to do is we need to disable everything, which is on sis objects already, like I already deactivated the Tetris block. On the other hand, if we don't want to do that, but we want to, for example, rotate this. We can create some small rotation script, which is going to showcase this particular object. Let's start with the Prevue or spawn a object. If you don't know about the position off the spinal object, you can also just take this one as an indicator for that we can do. Is we just created empty as a child on that I'm with Dragon outside on. We already have the correct position for the pivot point off one of our blocks. I can get rid off the C block in this game. Object can also get something like a name or even Aiken, just a showcase that this is going to be our spawn er or so we can rename this one to spawn are object once again, this does not do any actual spawning. Just takes care of that. The correct block is going to be spawned at this position. And that's going to so case in this particular camera over here and also takes care off, which is going to be that in Spawn, er I want to create a new script which is going to be accessible from wherever we like Teoh and we can talk to it sent the correct i d into the spawn er or to the spawn of object. Also, we could do the same stuff directly in the play field. But since we have a known object over there, we can also do this. Over here we go on our scripts folder, right click, create a new C shop script and maybe named this one Prevue or previa or whatever you please in like Proview of, for example might be good. You can also name this one prevue or spooner for Prevue. Whatever. Make sure you drank this script onto our spawn object like so, and open this one. I've been more no developed visual studio or whatever I d you prefer to work in? Once open, we gonna get rid of starting update because we don't need those. We can create a public game objector Ray with all our That's a preview pre fabs. So I can just or prevue blocks. So I'm gonna name this preview blocks. We also need is access er for this particular privy A So you were going to do the same as we have done before. We create a public static instance. And in this case, off priv, you're So we name it Revere and named the Proview instance Just instant, since we already did before quite some often Time in white awake. We want to make sure that we off course set the instance off this premier to be this particular instance off that now we need to have an excessive function which needs to be public void. And then we let's say something like so review on. What we want to do is we want to put in an index off type indicator which is actually representing the in text off this particular array Over here. What we want to do is we also want to store the currently sewn game object. So we say game object, current active or something like that, because we want to destroy this one whenever we do create a new privy over here. In that case, we can say destroy current active game object. This is important. So we can basically empty this complete sport and bring in a new one. We need to do this at the very first. We also want to do is we want to create or instance she ate one which is going to be sitting inside the province blocks and right to this insight, the current active. So we can't say current active is equal to Instant E eight. And now what do we want to Instant She ate is previous blocks. So the province blocks array with the index. We just pass in from the other script later on at position transform don't position and the rotation quarter nian dot identity. Also, we might need to typecast us into a game object. So we better do. Is that And that's actually everything we need to do to. So the prevue over here Don't forget to say it's the script and Let's go back to unity. Let the compiler run on. Whenever prevails, Blocks is going to be active. Over here, we are able to put in any pre fabs. For that, we basically just duplicate all our usual blocks over here. We're gonna select them all press control de to duplicate. And in this case, all the selected ones need to be renamed as well. So, for example, this one is not going to be. Maybe you can also keep the name, but you maybe want to say, see Prevue and you maybe want to do this was all the other ones as well, because these are going to be different for now. That's just renamed those. So all these which heaven now with one about behind it, we're gonna name them all to be prevue for me. All of them are currently in the center, so it's easy for me to track them. I gonna go through that raise a quick take your time. Was that Just make sure you get them or correct? What you might want to do is is you want to give them all one color or actually doesn't matter. You can also keep the colors s they are. What you don't want to do is you want to select them all and get rid off the tenders block script over here By pressing on the gee, I can remove component. Now, we just want to make sure that we have a good preview, meaning we want to rotate them around their own access. In that case, we create pretty quick and you see shop, script and named this Rotate me or something like that and opened this one up and mono develop or vision story or whatever i d once again you like. Once it's open, we gonna need update only over here we can, for example, give a float speed or rotation speed over here if we like to. And we maybe want to make a public so later on, we can define that in the Inspector based on the tile. We can do this just private. Basically, doesn't matter. So maybe I give it a speed of 10 an update. We want to rotate to this particular tile around. It's why access. So what, we're gonna do us? We say transform dot rotate around. And then here we can define a point and access and an ankle pretty good. So first off, we need to define the Axis, or in this case, it's going to be the vectors. Three point. The point is going to be the position. So in this case, transform dot position. Then in the next time we gonna put in the the Axis, in our case, it's Vector three got up, dusty up access, and the last point is going to be the ankle. In this case, we're gonna put in a speed variable. So speed, times, time, delta time. And that should rotate this piece automatically whenever it becomes active. Based on the speed setting we gonna have over here. Don't forget to save. And finally, in Playfield, whenever we want to create a the Proview, we need to change some code over here. But that's what we're going to do in the next video 47. #47 UI Finishing Previewer: Welcome back to the course in this part. We want to finalize all the steps for our Prevue. First off, we need to goto our pre fabs and select all of our prefects. We want to put the rotate me script on in this case or the Privy wants and we go to scripts and drag. Rotate me on all of the's. As you can see with the speed variable over here, we can easy. Just check it out. How fast? A whole slow this is going to be. Whenever we do press on start. You can test this out on your own. As you can see, 10 seems to be quiet, Luke. Maybe we want a lift it up a bit. So once again, I select all the prevue stones of a year and maybe make it 100. Let's see what's going on over here. Since we threw the change in the pre fabs, it also will be over here in this part over there. This still seems to be quite slow. Maybe we're gonna lift it to 200 that should be good to go. I'm gonna get rid of our preview part over there or piece of block. And now we just can actually get the priv your run of the day for herself and previous blocks. We gonna need to make sure that the order is going to be the same as for the ghosts s well , us for the normal blocks. So the first or the most easy part of years are gonna select them all truck top to bottom by their letters. I'm gonna make sure I hit this born off first hit the little lock symbol once again. So, like them all from top to bottom and just drag them into the brief, your pervious blocks. So C I a l o s t should be the same as in. I will play field whenever we deactivate. Look again. See, I l o s t make sure you have that. Otherwise, it doesn't make sense. Now we just need to make sure that we get us Soto work that our playfield talks so that our preview a script and tells it which I d to spawn next and also in play field. We gonna have to save this information to do so. We need to open on Playfield script in here whenever we spawned that we already do the randomized index directly in the spawn peace over there. What we want to do is we want to randomize that before we do the actual spawn, like one piece before that happens. In that case, we can create another function over here, meaning we gonna create a public void on. Then we name it, maybe calculate Prevue. So basically, we don't do anything else but this one. What does it mean is we can a tank this random in next calculation and bring this over here ? The downside onto that is we cannot take this random index wizards, and we cannot to do this just locally as this part. What we need to do is we need to define random index before or actually safe that somewhere . In that case, we go to our top over here and bring in and random in next integer over here. So what? We can do us before we do actually do the block spawn of there. We randomize the next block already and as well as setting this one up to whenever or tow whatever we liked you. So what does it mean? First off We want to make sure that the random index becomes calculated before the new block becomes spawned. Meaning we need to always sink one step ahead. So what we now do us? We have to call calculate Preval after we're done with spawning the block over here. So first off, that means we're gonna calculate a prevail meaning our random in this get filled by any random number. And here we still now access to random in next. Because we know a store this over here in the top. The only thing is and start before we spawned the first block over here is that we're gonna go and calculate the purview at the very first as well. Finally, we just need to talk. After we're done with calculating the privy over here, we need to talkto a preview. So we say prevue dot instance don't so prevail. And now what we need to do is we pass in random index because that got calculated after we're done with calculating our prevue. So once again, first off we calculate the privilege for the next stone. We gonna spawn whatever is inside the random and next and in the next or whenever this has created the next one is crook already pre calculated whenever we spawn, the next one calculated probably has run already because of that, and we can also show the purview for this particular or the next stone. Let's test this out for now. We get Go back to unity and see if there are any a compilation Eros. If nothing happens and everything is fine, our consul states clear. Don't want to make sure. Of course, we at least safe once make sure was born. A set up on a spoon or index, I may be renamed this one to Prevue Spooner. So maybe it's a more efficient name. Safe again. And now I press play. Let's see what's going on. As you can see now, this is going to be the next block over there. God calculated to be one of those long pieces. As you can see, it also works. The next one is really a long piece. Now the next one should be one of these squares. And as you can see, the priv your works. The only thing is, the Keira is not at the corridor at a good position over here, so maybe we want to reposition that The best choice to do this is paused. The game. Take your camera, bring it into possession. Wherever you think this is going to be a good 1 may be a bit far away so you can see also long pieces later on. Maybe that like that. Now you have all the transform information over here. What you want to do is you want to copy this component and pressed up. Now we want Teoh paste component values. So the ones we have already pays are copied before and now everything should work as expected. And the government should be updated to you as well. So you can see now we have this one in the center. The 1st 1 of course, does not get any privy over here. Only the 2nd 1 and everything works. And you can also see that the one is going to rotate around its pivot point Pretty good. Even the long peas is going toe work. And we can prove you that. So we know. Okay, We get a long piece next time so we can pre sent our self or crime pre set up ourselves to get ready for the next stone and bring this to wherever we like. Teoh. Pretty good. So once again, whenever we are now, we're actually going with our camera around, as do us through this little block over here. We are unable to see what's going to happen behind it. Also, we gonna later on take care off this part off a day like game over. 48. #48 UI Score Layers Level: welcome back to the course in this part. I want to prepare everything for score level up and in this case, also speed up. I already pretty much explained what I would like to do over here, meaning depending on, for example, the score or the layer we already have. Actually, you have fulfilled. We wanna increment the level sooner or later as well as we gonna check out how we can increase score depending on how many layers we have cleared and also score should be updated by that anyhow. So all of these are you eyepieces. So we need a connection to a U I interface which is actually giving us the possibility to put in this score. And also we need an object which is going to hold all this information off course. We could also create everything about it directly in the play field, but we want to keep everything as clean as possible. What does it mean is rather simple? We want to create a new object which is going to take care only off score. This object for me is going to be called game manager. This game in the jail will keep trunk and take care off everything about scores, settings and all the other stuff later on. So what does it also mean as we need to create a new script which is going to do all that stuff for us. So we're gonna create a new C job script and named this game manager. Once you have that and we type in a big G and a big M, you're gonna see this gear I can over here. That means that you're gonna find this easier. Well, your game in and just going to be I'm gonna re sent this. I believe this gee assemble was introduced in the unity 72 k 17 I'm not quite sure if you use older versions, you probably don't see this, but it doesn't really matter at all as long as you can read the name, of course. And of course, I want to make sure that I dragged this one onto my game manager object and open this one in mono developed licious studio or wherever you prefer to. Once it's open, we want to make sure that we're going to have these indigenous four score. So in school, I don't wanna have an inter job for, like level, which is going to represent the current level. And, of course, maybe layers cleared or something like that, or layers completed or just layers. So what we gonna start with is, of course, level one, and also we thought with the score level zero. So what we need to do is we need to re calculate all of that whenever we need to. Like, whenever we clear a layer, we're gonna update score as well as we gonna update. Like everything. Whenever we talk to a specific functions, recalculate the level based on whatever may be the score or whatever you want. How do we do this? We can define several different statements for that. First off, we want to make sure that we get a connection toe update the score. Loveland clever or layers cleared we can do is what you need to do is at first we need to have an access point. So in this case again, public aesthetic game manager instance and you guess it right in void awake. We gonna set this instance will be equal to this as you already know about. We already learned this. So moving I want to do is we want to update score, For example, when we clear one layer, you can also do this. Whenever you drop a stone, you can give yourself or your your players some points. But most of the time it doesn't really make sense. I believe so. Well, completely up to you how you design this If you want to do it like OK, I drop one stone and I give some points. Then you need to create several different functions to update everything accordingly. First off, let's talk about score. We gonna need to create a public void. And then again, something like set score, Okay, close parentheses. And of course we got to this since we don't know the score over here, probably. Well, at the moment we don't know anything. We can implement amount as an integer, And what we can now do is we can say score plus equal amount, something like that. Super simple, easy to access, easy to update and so on. We also can do is we can Whenever we sat score, we wanna update the you I later on. So I'm gonna make a little comment. Over here. We can also do us. We can do the same with level cleared or layer cleared, for example, we're gonna do the same stuff we great in you public avoid layers cleared. Maybe we're gonna do with the big L. So we don't get any problems later on with the naming convention layers cleared. And then here we just was the same layers cleared plus equal. And then we, of course, need to implement into amount, adding here we're gonna say plus amount. So this way we can easily excess all of that off course. We need to update the why at this point, it's well, we can also combine those two depending on once again if you want to only have one access point where you always want to put in layers can always want to update set score. You can put multiple things in a row over here and update like everything. Now we can also talk about how we can calculate levels. For example, if score was lower than a specific amount, that we can say level is going to be 10. So I gonna do an internal void calculate level. Of course. At the very end, we want to update the wife for that. But we can now calculate everything based on the layers cleared or even the score. For example, if our score is smaller or equal, let's say 10,000 points. If that is the case, we want to make sure that our level it's one so level is equal. One we can do this, like was a couple off even l statements over there. Toe, create some span to check out. Next one is going to be else. If score is higher than 10,000. End score is lower than 20,000. For example, we cannot say Okay, core level that's going to be, too. If you have, like of five different levels where we're gonna set different speed variables, then we can do this. No problem at all. We just need to define the span over the for example, we can do else of else if else if and then we say okay from here, higher than 20,000 and lower than 30,000. We can also say lower equal because and here we check only four higher ones not here, higher or equal. So higher than 20,000 higher than 30,000 higher than 40,000 higher than 50,000 for example . We can now do it over here. We need to do the opposite or actually the ones which are capping this complete part. So it's a smaller equal, 30,000 small like with 40,000 smaller equal, 50,000 ants mola equal 60,000 over here. And now we need to update justice levels. So we can't say level is going to be three level for here is going to be four level is going to be five and level is going to be six. You can do this up to 10 for example, and then you keep track on that. So everything which is higher than 11 million points or 100,000 points, absolutely possible. We can actually do this until 10 because it probably makes the most sense over here. So I got a duplicate this, like for the seven for the eight for the A nine and for the tent, and we're going to stop a 10 of course. So once again we have 456 and here we would go for level seven, the lights level nine and Leviton. So once again, we don't need this camp over here. We're going to stay at this point. It should be something like 100,000 I guess. I don't know. We're gonna check it out pretty quick. So this starts at 50. This started 60. This starts a 70 at eight. Okay, This one is going to be nine. Since we have level one until 1000 already. If you don't like this spans over here, you can always take your own score. You can also say 100 to 201 105 101 or 2000. Whatever you want. It's absolutely up to you. You need to design that on your own and see if the people are even able to play the game. However, how hard you're going to make it for them. So in here, we're gonna need to say is equal to 60,000. 70,000. 80,000. 90,000. And over here we are going to be over 9 990,000 and then we're going to be at level 10. So and what we can now do this We can sent also a speed to based on that. So for now, I'm gonna take a float and name this one full speed. So and we're gonna need to have an accessory to read the full speed, the calculated full speed and update our tanks blow or temptress blocks according to the calculated full speed. But that's what we're going to do in the next video. 49. #49 UI Calculate Fallspeed Score: Welcome back to the course in this part. We want to go and continue to work on the game manager so we can calculate the full speed automatically based on the level we are in. Also, we need to create a connection to score text level, text layer text and all the other informations. First off, going open your game images script and we need to have the possibility to read the full speed over here. For that, we're gonna create a public function once again public. And in this case, you want to return afloat because four speed is going to be afloat. So public float read full speed. So we want to read this information whenever we call this function pretty helpful because in this case, we just need to return Whatever full speed iss, We don't need any excess from anywhere else. Just by that, we can just request it over here. But it's still sti estates private, and nobody else can access it only over this world function, and he only can read This we now need to do is we need to calculate the full speed and we need to set this based on the calculated level, for example, so meaning whenever we are in level one, we want, for example, set the four speed to be equal to ST. This is rather slow, so the people can actually start to learn the game, have enough time like three seconds until the block is dropping at least once and over the levels. Whenever the player just have the even better feeling on that, they can absolutely go into this and reset all this information. Or actually, you actually go higher with the speed over there until they have something where it is ticking superfast down but might not be as good as manageable as possible. So, for example, in Level 10 you want to have the full speed to something like one. So that means it takes one seconds to take this next block down on the current block down, or probably want to make it even a bit tire like you 10.8 or 0.50 point two. Well, that's kinda unplayable, but because off the input poor problems, but one second is quite a good challenge already. I guess so. Now you don't need to find a good calculation that say between three seconds in little as a level one and one second as a level 10. So you need to find a good balance between those. You can always do some fancy calculations. Well, at least we just need to divide and number two between doing Yeah, with eight. So we can say two divided by eight is zero point to fight. So if we per level reduce the full speed by 0.25 we should have have an even a full speed reviewed reduction. So in this case, four speed, it's equal toe. And are we gonna say negated three by 0.25 So we land by two 0.75 and we need to make sure this enough behind it. I'm gonna copy that. Bring this over here and here. It needs to be 0.5 or 2.5 in here. It's going to be 2.25 and never five. We're gonna have a full speed off to I hope you get the calculation. Once again. You can do your own calculations with that. And here we gonna have now won 75. Copy that. And here it's going to be a 1 50 So 1.5 here we have one, 25 And in here. Well, we're gonna have the one already. So I just did a wrong calculation on that, but not problem at all. We can also reduce even that of a day. So maybe at this point, we gonna have a full speed off one. And I make this 1 may be super heart 0.2 point eight or something like that, or even 75 should also be a raza. High challenge. Okay, so now we have all our levels and the full speed. So meaning per level, Everything in decreases in case of force pizza. What? The game becomes faster as well as we gonna have A with this level. So the player gets an indication off. Okay, I increased my points. I have no a higher level and so on. And that's everything we need so far. Now we just need to update or calculate the level. But how do we do this off course? Whenever we are setting the score by whatever is coming over here, we just need to make sure that we calculate the level every time we gonna set our score. So in that case, we can say calculate level, open, close parentheses. Close the line was a semi colon. Once again over here, we want to make sure that we update everything once again. Also was a layers cleared. So whenever we have a specific factor which is going to update like everything at the same time, you can just put in another argument over here. For example, if I set score, I might want to make sure I have a layer cleared. So again, also put the layer cleared information in set score. And Jen, just make use off this update function over the once again. It depends if you want to, Ah, take set, score, separate Lee or if you want to combine them like a chain or you want to update like everything only when there is one there cleared. So in that case, when 11 layer cleared, we can also calculate the points over here. So how do we do this? Basically, we can do all that stuff like we have done already before. We going to do some if tax and the highest amount off layers which are able to be cleared is anyways four. So if the incoming amount is equal to one, we can say OK, I was score increases by 400 for example, so we can call set score and passed over 400 points. That's my calculation. You can do your own now. We can do this with all the other ones as well. So else if amount this too, we might want to go and give 800 points. If it is three, we want to double that as well. So we get Tell them, thanks on 600 points and the last one over here is going to be with four amount, which is going to be the maximum we're gonna give. Maybe the double off that is 3200. So the more in case of combo the players are going to create the more points in the end that will get pretty good. Now we update the score whenever we call layer cleared by this amount of points. Once again, if you want to send scores separately by whenever you drop just one stone, then you can also call set score Over here 50. #50 UI Calculate Cleared Layers: welcome back to the course in this part. We want to make sure that whenever we clear a lie other we get off course the points. And also we calculate how many layers we're gonna have actually cleared in that particular point over here to do so. We gonna open our Playfield script and go to the function called delete Layer. You know, we're going to check for full layers at this point. Are we going to delete all the blocks which are sitting in this layer? Well, we can also do is we can pass in a local introgen an update whenever we're done with this complete Tak over here, the very end. We can update our game manager to call the function layer cleared or layers cleared and pass in the clear amount. So what we do is at the very first before we gonna go into the fall up, we create a local temporary into Gia called layers cleared or something like that. We need to define it so that it is said to be zero at the beginning and in here, whenever we are going to count that or whenever we're knowing, how can we have a fully and we found one. We gonna increment layers cleared so layers cleared. Plus Plus, whenever we're done with the complete follow with the complete Jack, we're gonna have any number in case of layers cleared over here. If we have zero, of course, we don't get any points. So what we can do is, if less cleared is bigger than zero, then we want to make sure that we update or gay manager. So gay manager thought instance, don't layers cleared and then we pass in the layers cleared. So the ones we were counting up over here don't forget to save, and that's everything. Now we just need to connect the user interface to that so the players can see anywhere. How many layers to have cleared in total as well as you know, they're going to see the points they got for clearing one. There 51. #51 UI Text Elements: Welcome back to the course in this part. We want to continue work on the you Enough to visualize how much score layers cleared and level we're currently have. What we need to do is we need Teoh actually create new text elements and make them so that they are sitting in our canvas. So in this case, the can was were also a button this insight, like both buttons as well Asama Prevue Also, I renamed my camera which is doing the Proview to be a prevue camera so we don't get confused by our target camera over here, just in case. Once again, naming convention is always king in canvas. I want to create now something like maybe an empty or we can just put the connect since directly inside does not actually matter. Let's assume we don't have any empty game object and that we gonna create a new u I text gonna rename this one because this is going to be my score text. I can give it some color. I can bring it to wherever I like. Teoh Currently it's located over here. We can barely see this in the game view because off the color as well as the size. So I make it may be white. Maybe make it bolt. You can always dragon your own funds. If you like to, you can make it the best fit, so it will be higher than that and probably want to stick. This may be in the bottom set or in the top center. Want to the right? Only every poison, like since score usually can be quite big in numbers because, as you've seen, we can be higher than 100,000. We just need to keep that or keep track of that as well. For example, we can only put in a number over here without any text we can also pay. Put a line break over. They were gonna also just say we are. You make this in the top over there, so it's not distracting us too much or maybe above the purview or wherever we like to once again another design decision completely on your own. What do I mean by that? Let's assume we type and score Colon, and then we're gonna add, like 10 or, let's say, seven numbers. Some zeros. 1234512345 So we have 10 numbers now. Maybe not a score, which is actually reachable. But what? We need to make sure that our field is going to be big enough for all these numbers. And they do not stretch completely over here and go to two D view And to select this tool V of this actual rectal select that port and asking I can now drag around to the right, into the left. Everything is no stick to the left, which is good now, since I know. Okay, this can be the size offer here and probably we not have one million points. Actually, we have the maximum off 900 or nine million. 99 then this might be a good size over here. Also, depending on how big this is, you probably want to see where I want to put this. But I guess this is not about that. Ah, here. Point of your, like, centered to this point and claimed to the right once again, or actually anchored. So that's anchor this to the right first. So the anchor off. That's right. And now we dress drag it up once again. So once again. Make sure it is not in the play field. So the player has enough space to, you know, play the game. If it is to sense to a huge make it smaller just, you know, like this. Same for the other ones. We're gonna need another one for the level. Maybe so. I just duplicated this text and bring the stone, and we need a now have another one for layers cleared. Usually there's something like Rose cleared, but that's a fine. We don't care about this too much. So in here, I'm every type in something like level colon and then a number, or this is just our level text first and in here. I gotta put on level colon, and then the level we're currently in. Maybe you want to make this level bit bigger. Both once again, totally up to you. However, you want to manage that, for example, you can a direct this a part of it, so it's a bit more prominent. You could also center this because more than 10 levels are not in a Tetris game anyways, So we can, for example, make it so that this text always, even if it is just a level one. We put in something like 01 So we always have this complete correct size. In that case, we can also center the text and bring this over, Take it or keep it over there once again, a lot of design decisions completely up to you. And then we make something like layers colon and then something like maybe 10,000 or even more. Once again, this number can maybe not higher than one million over here. But that takes quite some time already. So we have this amount off layers cleared this amount of score based on the layers cleared and, of course, the level we can see now. So the final step is we need to create some connection points to these three texts elements to update everything accordingly. 52. #52 UI Update UI: Welcome back to the course in this part. I want to create the connection to this text fields and update them accordingly. We need to do is we need to create a script for that. I gonna create a new seizure script call you. I handler, this handler only takes care off. User interface stuff like score level on text fields. We don't need anything else from that. Just for this toe, update the score text accordingly. Open this one in mono develop or vicious studio. Once you I handlers open, you just can get rid off. Starting update since we don't use them or need them. Well, he does need to have is a connection to all this re tax fields. So they need to be public off type text. As you can see, text is not in my list. That means we need to have to bring in unity engine, don't you? I name space. I can't simply just right. Click quick, fix unity. And in don't do I If you don't have that for whatever reason, you can also type in here using unity engine dot You I So you have access to text elements now? We give it a name, score text. And we also need the text elements for the level and for the layers we have actually fulfilled or actually in our game. So this is going to be the level text, and the last one is also a public text. In this case, it's going to be our layers text. So how many layers we have cleared? Now? We need to update these. According to whatever the score amount is, the level text or level amount is as well as the layer text. Once again, we're going to call this late on from the game manager. And to do so, we, of course, once again need to create a public aesthetic instance off the you I handler so public static. You, I handler instance and was, say, white, awake, open, close parentheses. And here we say instance, equals this so we can talk to that easy. No, we just write a function over here. What does it mean is once again we just say public point, we name it, maybe update you I or text. And now we need to put in all the information we gonna have inside the game Manager. What does it mean we need to have something like end score? So the incoming score or the score we have calculated inside the game manager, the level text or the level we already have in the game and Jessel end level. And finally we gonna need to have the layers we have cleared into layers. So these three informations no need to be updated by us and need to be sent inside or to the score text. So we're gonna say score text. The text is equal to score. Don't to string and open close parentheses, but in front, off the score we wanna have a string already. So we say score colon space. And after the colon or no. After the quote, we're gonna put a plus. So now it's typing in score leaves a space. And then it adds this incoming score, which gets converted to a string. Same for level level text. So text is equal to level colon space, plus whatever level is thought to string open doors, parentheses, close. The line was a semi colon and the last one once again it's layers, so layers taxed, don't text. It's equal to quotes, layers, colon space plus layers dot to a strength. If you want to actually make sure that you only see two numbers. Always see two numbers has already explained in the level part, we can end that. Parentheses. Put two quotes and put in D two e two stands for decimal two, which is inside the dotnet library. You can check it out. A. Probably your I d is going to show it for you. For me, sadly, does not. But that's OK so you can do a Severin of different formats by using something inside quotes . So four score. We probably want to always seat nine numbers. So against a decimal tour de to in quotes over here. Same. So we always see nine numbers in layers, nine numbers in score and two numbers in levels. That's it. Don't forget to safety you y handler, and let's go to our canvas. I want to make sure I bring the u I handling it into the canvas because the canvas always has the connection to all these texts. I'm gonna name this one over here two layers text because I want to make sure I have everything. Send it in later on. Correctly So here I have the connection. I now drag score text level Texan layers, text into these slots to get them updated accordingly. Context level, tanks, layers, text and we're good to go. Now, whenever we press play, we need to make sure that these become our updated at the first run. In that case, we need to go to a game manager into our awake or even start miss it and update everything accordingly. So in that case, first we need to calculate the level. So in what we do is we say white, start open, close parentheses and and curly braces. We gonna go and update everything accordingly. Also, we need to call the update you eye. So we say you I handler don't instance, don't update you. I opened those parentheses and close to nine was a semi colon and start. We just call, set, score up, close parentheses and close the line was a semi colon. In here we just pass in score and that's everything we need to do and an update. You I we want to update like everything we need to update over this. So first passen score second is going to be level and the last one is the layers cleared. Don't forget to safe. Let's see if the compiler has any problems was that doesn't seem so. And whenever we press play, we should see that we are in the one hour score gets updated to 2000 and our layers are also falling off the rose. Now we should be able to play testers completely. 53. #53 UI Update FallTime: Welcome back to the course in this part. I want to do one final touch for our Tetris blocks directly and I want tenders. Blanka. We decided to have a starting full time off one second. But since we re calculate the full time inside our game manager every time we are going to have a different score or based on the level we wanted to make sure that this full time or full speed gets actually read it from any Tetris block, which is going to become spawned. In that case, After we're done with setting the button inputs and stuff like that, we want also update full time. In that case, we're gonna set full time to be equal to game manager dot instance. Don't read fourth speed and open girl's fantasies. Now we sat full time automatically every time a new treasures block respond according to whatever the co calculated game manager, full time or four speed is going to be over here. Once again, we owe actually just returning this number from this particular function of a day. So now whenever we, of course, safe the script and start to play the game every Ted Rose block is reading the correct amount. The correct number. A second seed gets created and takes three seconds now until drops at least once. That is good, because now it is deter mined, based on the level how fast these blocks are falling down later on, whenever we're in the higher level off course, we want to make sure that this is going to be you can pre calculated or re calculated. That's already happening whenever we are updating the score. So in that case, the player, whenever he is a new player, has the possibility to learn the game first. So we give them the possibility to do all of that, increase the score based on the layers he's going to be able to clear, and then he can update everything accordingly. I'm gonna speed up the process a bit and willful for at least one layer. So we are able to check if all our coat is going toe work like we want to make sure that our scripts are working and the other stuff as well. Now we should update the layer. Whenever we fill one there, we should be updated level or the layers to be one. And the score should be 400. Let's see if that works. I can see the score gets updated, but we do not update layers. So what we need to do is we need to actually update this layers. Text s well, to do that, we're gonna go it back into a morgue. A manager script. We have toe update the Y at the very end. This Well, so in that case, whenever this has happened, whenever we have cleared the layer, we gonna call the same as we do in set score. So I called me that line over here, and then here we just say Arm day. Do I, handler instance, not update ey by score level and layers cleared as some final touches. You can also go into the pre fabs for the preview and make sure that all off the pivot points off, the rotations are going to be. However you like them, for example, for the LPs Prevue. I might want to check out the rotation point in this case. My irritation point is over here. Maybe for the prevue, it's better to be here in the middle to do so. We just take the cubes snip, drag them like here. So whenever we are rotating now, the L it is rotating about its actual year long peace center. Once you're done was down. Apply the changes to the prefab and you're good to go. Was that I'm gonna do the same or something similar to the Opie's? Because at the moment it's like waggling around to the site and is not really rotating around the center for that piece. I would go and bring the pivot point over here. In that case, gonna take all these cubes brings them one to the right one down. And now I need to go go into the same for the side. So I need to bring them all Ah, half in front like this. So once again, do all of that snapped. Whenever you are now rotating this one, it is rotating around its actual center. Don't forget to apply the changes, and I'm good to go with that. The other ones are more likely, like I want to see them once again. If you don't like the pivot point on this CPS over here, you can also bring this anywhere else like here by the belief this is going to be a good sport for that. Or you can also take this as a sport of here. So or in this case, over there, so it can rotate it direct around the spot like we already do with the pro Proview peace over there. Once again, you can always check it out. Hold Those pieces are going to look and then we're good to go with that. Don't forget to save your scene. You have done any major changes and then we can go forward. 54. #54 GameOver: welcome back to the course in this part. I want to talk about the game over. What does game over mean is whenever we are unable to place a new one at very start, whenever it gets basically created, we want to make sure that we sent a message or something are very able to our game managers . So the game engine is okay. It is game over, were unable to move, and also we do not want to spawn even more Tetris blocks in the end. So let's adore the structure for that first off in our game. Manager, we might want to go and create a bull for that. So bull game is over. And, of course, at the Barre basic, it is going to be force you don't need to necessarily put in is equal force because whenever it starts, it will set to be faults automatically. Now we need to have some excessive point to read if the game is over or not. In that case, we basically you just return the bull as we already do. Where's the read full speed, for example? So let's create that at the very first we need to excess of points. The 1st 1 is we want to set Game is over and we want to read Game is over so we can make use off centers and get us if we like to, or we just create to single functions over here. So first public bull return or read game is over, and then we just inside over here. Return. Whatever game is over is but without the Prentice's, so we just return it at this point. Also, we need to have once again a connection to set game over so we can say public set game is over. Whenever we call this function, we want to make sure that we set it to be equal to his game over. Of course, there's the self type Voight. Otherwise, it doesn't make sense. And in here we set Game is over is equal too true. Don't forget to save the script, and let's go back to the Tetris block. The Tetris block is at the very first time, of course, is going to go and spawn a new block inside a while. They look, meanwhile, is falling down whenever it can, meaning. Whenever there's Novell attack, Orvella move anymore we can basically do the same. Check it start. So if, well, it move in, start after we have done everything else and setting up every singles. If we don't have any developed move left, then we can say, OK, the game is over because we are unable to do of Elop Move for never. We get insanity ated so we can talk to the game ended. Joe Not instance. Don't set game is over. Also in here, whenever we are done with that, if there's no valid move left anymore and we would usually do this Jack or would spawn a new one, we want to make sure that we check if the game is already over or not, because both are basically working hand in hand. So we just over here, make sure that we only spawned a new block when the game is not over. Otherwise, it would just not work in this case. So we're gonna put another if statement. So if game of game manager thought instance don't read, game over or read game is over. That returns true then, or in this case, if it is not returning, so it is going to be false in this case, so it it does not return through. We want to make sure that we are able to spawn the new block. Let's test it out. We're gonna go into unity. Don't forget to save everything at the compiler run until it's done. And let's press play. What I would do is I would just speed them all down until I'm not able to do anything anymore. As you can see, it took two pieces to actually get the game said to be, It's not over and the next piece would be just that. But it is actually not possible. Well, to do anything else at this point. Also, whenever we're setting game over in the game manager, we can also start something like an animation or whatever we please like to represent that the game is over. So in that case we can probably go and create, um I numerator, which is going to do some time based action, and in the end, we're gonna go and show some user interface. We're gonna do stuff like that in the next video 55. #55 Game Over Window: Welcome back to the course in this part. I want to create a simple game over screen where again on which we can actually show. Whenever off course, we're going to become game over later on. You might want Dio animates tougher Do some a fancy animations like filling all this complete grid was blocks from top to bottom or bottom to top something Teoh showcase that the player is not able to do anything anymore to create this game over screen, we go head to our canvas and in here I want to create a new image. So this image is basically I want placeholder as well as our ray cast block item. So in that case, we go to you Why image And I want to make sure that this is completely spread it over the complete playfield and is above everything else. So this image is going to be our gain over window or something like that. So this one is the one we gonna late on activate whenever we lose, and then we showcase. I want to have this one spread it. So I hold on the old key and select this little window over here. Also, I want to go in to bring this one, maybe to be a super blank and I want to reduce elf a bit so we can still see through it. But well, not as much as before. So, as you can see, it is now a bit transparent and lays over everything else because it's at the very bottom off our Candace. What I also want to do is I want to make another window in the center where we gonna have, like, game over, and with them we're gonna show the score. If you don't want to have a window, you can also leave it as is and just bring in a big game overtaxed into the center. So all of that, once again, is up to you. Maybe you also want to put some buttons next to it, like under it something like play again or back to menu or whatever. So I gotta go and do a very easy one, since I guess we don't need to do much over there because we see the actual score. We have Regis Wells, the level in the layers at the very right, So maybe are going to make a big red text over here in the center. So game over and then we're good to go and I make a rat's Make it bold. Make it a best fit. So it fits. Always asbestos. It's Can my text field gonna make it center? Maybe you say something like it game over. So and I want to make that so that it is a bit bigger. Go to to demote wrecked tool and to drag it how much and how big I want. If that is not huge enough for you, you can always go and, ah, make best fit. Maximum size to be, let's say, 60. So it's even bigger, bigger and more represent over here or prison at all. And then you might want to go in center, this one. So everybody knows. Oh, damn, I'm game over. They were gonna make this overview. We know not black but rats. So it's even more present. So the player really knows. Oh my God. I did not make it. Maybe No, too much. But we want to have a difference between the actual gameplay window or the gameplay stuff. End our game over screen once again. What we can also do is we can create a button for, like, simple, back to menu or replay. So in that case, we just go to you. Why button, when we say something like this is our web back button? So we go back to the menu and of course, we want to make some text over here something like also back to menu. And maybe I'm gonna make a symbol. You can also make use of images. You can use whatever you like, and we're gonna make sure we dragged the button somewhere in the center like we can see where it is going to be. Once again, if you want to have replay button, you're absolutely able to do this year as well. I want to make sure my Texas going to be all the text on the button is a super black and bold as well, so it can be seen quite good. Also might want to increase the size of the button a bit more so it is easy to touch also this text I might want to go with best fit over here, but also I want to make sure that this is not too much like it is not going above the border and it's still going to be centered and is all written in one line. Once again, you can also do a replay button over here. So since we don't have a menu, we are not going Teoh create the script for that right now. But we want to make sure that we are able to activate the game over window. And to do that, we need to go into a game and just gripped and connect this window to that so we can't actually showcase this. Also, we want to make sure that we block light on the input over or throw this particular yeah, image over here. So usually we should be able to use something which is called like a canvas grilled. And in here we should be able to block rate casts when this window is active. Let's test out if we're able to drag around stuff as you can see my camera still active. But I cannot do any switches over here. I cannot press on these two buttons like speed down and switch. That's okay so we can basically deactivate the camera later on. If we like Teoh, so we are not able to rotate around. But actually it doesn't really matter as long as we are able to press on the back to Menu button, and that's what we want at this particular point. Once again, when we're game over, we can also set this window to be or the camera target camera script. We can just deactivate this whenever we are done with that, or give some automated rotation or whatever we place in, like once again, totally up to us. Also, we shouldn't be able to touch any of these flying around buttons over here to move anything else further. That's good. So now we have a working a game over your window over here, and I would go to our game over a scene over there. We need to create a connection for us to our axle game over window. So we created your public game object and call this game over. Window was a big was a small G over here. Now, whenever we are game over, like whenever we call this function with said Game over is going to be equal to true, we're gonna set game over window, not sad active to be true. Also at the very start, just in case we want toe set this one to be equal to force. So at first we're gonna set this window to be equal to force. So we don't see this whenever we start the game. But when we are game over, we want to activate it. Don't forget to save the script. And now we go to our game manager. Then we go to our game over window and put this over here. The more efficient way probably is going to connect it to the canvas to our you I handler. So we sent an information to the U. N handler and say We want to show the game over window from that point. Maybe that's about a choice, But let's test if that works for now. So as you can see, the game of a window gets actually deactivated, we are able to lose. And as you can see, once we're done with all of that, we lost already. Then we can only go back to the menu. But we cannot do anything else but moving. That's functionality. Pretty good. So once again, to keeps everything according to whatever test today, we're gonna have put this complete partner inside the EU I handler, which might be a more proper or best or better way to do handle this. So since we have connections and here already, we go to our game manager once again, we take away this public game object game window and just cut it out. Bring this over here, take away this functionality. Also take away the functionality from that. Don't forget to safe the game manager and in here, we gonna create to function. So first void start and set game of a window dot said Active Toby False from here. So we keep everything about you I inside the white handler and now we need to have another excessive function to activate the window. So public Boyd set game over window or something like that. So in that case, we just activate this, or we can also say, Activate game over window. Maybe it's a better name. Activate. And in here, whenever this function gets called, we say game over window. That's had active to be true. And the final step from the game manager is no to call. Activate game over window So whenever the game is over, we gonna say you I handler, for instance dot Activate game over window guards, parentheses and close the line was a semi colon. Don't forget to say the game and don't forget to save the you I handler and let's go back to the canvas. Now let the compiler run and see if there are any issues. And now we can drag the game over window directly over here in the u I canvas. Because the canvas once again holds all the connection. We don't need to take care of that from the game manager. This is a way better practice, so keep everything at the sports where it has to be. Now we can test it out. Once again. The u I Hang Glashow Deac divided At start. We're gonna speed down several times. We lose, but the game manager just kind of late. Reiko organizes that we already game over, but still it does the job, and that's what you want it over here 56. #56 Menu Scene: Welcome back to the course. Now, since we are basically done with the complete game design, we can also go and create a man your scene. The menu scene would just So what the game is about. Probably give us a play now, button. And then we're going to this one on from here. We are able to go back to the menu or even replay one round if we like to. To do so, we have course. Go to file. New seat. This is going to be just an empty seen. We can design it to whatever we please and like, put in any you I elements we gonna like and so on. And so force. So in that case, I gonna create maybe some text and give it just a name something What can ever whatever can be the name of our game. That's a blocks three D or something like that. You can make it any color you like. You can, you know, 10 stuff. You can make any form. Do you like you can even bring in any graphics you like, Like screenshots from the game. Whatever. Or maybe you can do something in the background like moving belongs, animate them and so on and so force. So we're gonna have a blocks three d as our title. You can always go in to rename the text elements to be titled text or something like that. Once again, don't forget Keep everything clean and organized So everybody else, whoever is going to maybe work with you and one project knows what stuff is going to be about. Gonna change the camera over here to be something like, I don't know, lack of white or something. Graters. And I want to make sure I only use solid colors. If you want to make use off some of your blocks inside our game over here, you can simply do this. So what we need to do is we need to locate on camera and go to a prefects full. And we can, for example, make use of this Prevue ones over here. So we could, for example, direct them over here. Zero this one out. So we see them over there. Maybe a back white background is not a good idea for this. So maybe make it a bit more greyish or whatever you please in like you can also put some great graphics in the background. I gonna show that in just a second swell. And then you can just place well, not the camera that maybe this prevue ones over here late. Maybe one block at this point where I taken L into the right corner off my camera view over here. Maybe a gun on take Ah, this piece but the prevue one because there's a rotating. Don't forget that. Bring this over here and maybe another t block or something, which is also going to be of type reviewable block and gonna bring this in the other corner once again, make sure they're all on the same Zad axis or probably around the same s you have to do. Gonna go out of to demote to see where they are actually located. Yeah, this one needs to be at zero here as well. And maybe from once again, the two D mode or two D view. I'm gonna bring this preview one over here, into the corner, also on my canvas. I want to create a button to play the game, so I'm gonna go to you. I button and as you can see I can place this wherever I like to unrelated to this three D objects. Gonna give it to some text, maybe play, and we can resize it to our needs. We can also attend this. Of course we gonna unable direct tool to have an easier access over there. Maybe we're gonna make it something like that. Maybe center this or bring this at the bottom. If you have more in intense graphics, once again, all of that one up to your completely content this button, if you like to, you can redesign this to be a ball text, maybe to highlight it be even bit more. Maybe we're gonna increase the form size over here or we just do It was the best fit one and just reduce attacks element over there as well. So and now we just need to add the functionality for the play button and later on, also the functionality back for the other button over there. In that case, we're gonna create a small script which is taking care off only menu stuff like button presses. So we created you c sharp script called Menu Hendler or something like that. And this menu handle off course is going to sit for us here on the campus because it takes care of that. I just drag it onto it and double click to open and one of developer, vicious studio. Now we just need Teoh implement the management system for the buttons. Once it is open, we gonna get rid of starting update because we don't need those. We just need to create one excessive function to load the correct scenes. In that case, we can say using unity engine dot seen management. So this is going to be or name space we need to use over here. And then we create a public Boyd load seen function. We cant put in, for example, a string over here or in Integra as the integer off the built index in our game. I'm gonna make it a string because it's easier. So it's the scene name or seen to load. Whatever you name, it maybe seem to load. It's a better one. So seen to load and we in the button we can just define which seem want to load. And now we just tell the scene manager to load it. So see manager dot load scene, and now we can just say which one we want to load. It's going to be the scene to load. Don't forget to save, and that's basically ever seen for the button. Handley. Now we can make use of that from anywhere because we just need to make sure it is anywhere in the scene. So this button over here now gets an on click event. We drag our canvas onto it and go to menu Handler ensues. Loads scene, and then he'll we're gonna say something like Game. Since we don't have a game seen yet, we're gonna just rename our current scenes. At the moment, we only have the sample seen. So I renamed this 12 game. And also I want to say that this particular scene So I say, safe scene, go to my scenes folder and say, This is my men, you see safe. So we have the menu seen already. Safed, over here. So this button will no load the game scene, and finally, we need to make sure that we goto build settings and add open scenes. Make sure the menu is above the game. If you have something like a local screen or something similar. You can absolutely at this over here as well. And some other steps could be You could maybe put in some copyright taxed over here like brought to you by whoever. So, in that case, we're gonna create in you text field and bring this somewhere. You can also put in a version number and all the other stuff. So we go to you, I text gonna make this one also bolt and type in my text, for example, copyright by octo man or from ever whatever your website is, For example, optimum games dot com. Now you make sure that everything is readable and automatically re sizable. Maybe you might want to make a center and then you're good to go, and then you'll bring this to whatever position you want to see. This can, of course, to the tanks to going to make it white rent blue. Whatever your game represents over here can also put in your logo and all the other necessary information about the game itself. Don't forget to safe whenever we press play. Now we should see four rotating blocks over here as it can Also said this one resized to be wrong. And that's happening because we did not set our canvas to be Scale was screen size. As you can see, this is the actual one. So we no need to re skill some things because we forgot to set this up accordingly. I'm gonna make it so that I, X actually make the size off this text of it bigger once again, Center it out. You can always go in to make the button of it bigger If I like to a reposition my the link over year or my little text over there gonna make a fun size, Maybe it's bigger. So it once again fits in my design. If I like to impress playing, check it out to get I can't see It's way more prominent gonna have our play button over here whenever we press play all game starts and now we are able to play the game and the last step to finalize that we go back to our game. Ah, man, you're game scene. We saved the scene and in here for two hour back to many of button. We need to make sure we're gonna load the correct menu. You can put this also into the canvas over here. But the scripts, Manu Handler, you can also put this on the button, by the way, so it doesn't really matter where the menu endless. And in a while back button, we gonna make sure that we say plus draggin on canvas goes. Dad is handling all of that stuff. Go to menu handler, load scene and in here we want to loot the menu it entered to apply. Don't forget to safe your scene. And now let's go back to our other scene to our menu seen. So I go to scenes menu double click to open press play. Play the game. Let's lose pretty quick. Go back to menu and there we go. Now you have a raza Sollett year workflow. Inside the game, you see a game overseen or screen. You're going to see the point to score. You go to ready as well as you are able to go back to the menu. Once again, all the design decisions are completely on your own. You gonna have to take care of that. You can even do some fancy stuff, like taking a single cubes over here and make a cool three D years looking blocks text over there with just, you know, something like that. So B is going to be a raise. A big one. You might want to do it a bit smaller off course, and then you can even rotated. You can animated. You can do anything you like and please. 57. #57 Conclusion Thanks: So you become rez a successful in completing the complete course, and I want to thank you at the very first to take this course, and I hope you have learned a lot. Let's do some quick conclusion. What you have learned so far, you learned how to create your own menu, even with just a basic one. A simple menu. You were learning how to rotate three D objects like over time, you were learning how to connect scenes to each other, like by just simply loading them. You were learning out to interact with the camera or where you created a camera setting. You created like everything about the game, like Where do we spawned these objects? We gonna created this ghost blocks, which are representing and checking if there's a valid position to put on you'll. We're learning how to speak these things up, of course, and how to clear off layers, gift points and score level and layers going to be. I counted up and so on, and so force you were learning out to create a game overseen like this one with button interaction. Also, you learned how to disable these buttons over here in the background. You off course. Still have the possibility to look around to? Probably we gonna keep this at this point. If not just a disabled, the script on the camera, no problem at all. You should know how this is going to work without any issues. And we also created this privy over here, which is not visible in our game by just blocking away the information behind some kind of war. And that's pretty much everything we gonna have learned in this one. And probably there are some small things you have learned as well. Like how to talkto instances off other scripts without taking too much hassle and finding game objects and stuff like that. No, we just talked two already. Instance Yak scripts, which are just subscribing to themselves and say, Hey, I am this particular instance and Annie's group can access any other script without any problem. With that knowledge, you probably can be a create even better, even more advanced games because the process and the principles are going toe most of the time stays the same. So go out to the world right now. Make sure you release this game or create another one. Maybe you want to go into the graphics and maybe make it more rounders. More bubbly. More? Yeah, whatever. And then just make sure you release it. You bring it out to the world, tell other people you tell your friends you have created your very own Tetris game or Tetris style game over here. And don't forget to rate the course in any way. Maybe you find the time and right a small command on this course until other people's how you think about this course. Once again, Thanks a lot for taking it. I hope you enjoy this one. Once again. My name is optimum in and I hope I served you well. See you in the next course. Bye bye.