Unity3D Game Development - Fill the Line - (full process) + (w/ guest Charles!)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right I just went live too so I think I probably have to close I'm live baby lots of things are we gonna hear myself talking in two seconds but all right hey everybody so I think we are alive now it's like there's a lot of people on here with Charles as soon as Charles talks hey guys hopefully I'll pop up soon what's going on one day I will figure out how to do this side-by-side streaming stuff we actually show up side-by-side and zoom we're gonna be doing a lot of desktop sharing today though so it probably won't matter too much but the plan today was to do a couple things first answer a bunch of questions if you guys have questions just about general unity stuff game development stuff that we can answer and then we're gonna build out a little game so take a mobile game build a clone of it go from a completely empty project we'll go through the process of throwing it together building it show all the kind of problems and issues that come up and the things we stumble with and then after it's done or do another version of it where it's like be nice completely edited clean version so kind of like what you normally see in a YouTube tutorial and then right now we're gonna do the live behind the scenes version of it first so you can see that all see it all kind of come together and ya know that it's not always just magic right it's not just like you do it and you always know the right thing the first thing that you do works perfect so that won't be what you'll see today but we'll be taking questions and stuff and then like I said the full version or the edited version will be available so if you just want to do the step by step and not see all of the problems should be able to do that as well anyway I think Charles you're live streaming um too right yes I am if you're on my channel watching make sure you subscribe to Charles stuff he's got lots of great content there and before we get going if you don't mind just hitting the like button and the share and all that stuff it does help just get more people in here and let more people see what's going on in hopefully make people better game developers sorry I'm like looking off to the side but that's where all my chat is it's kind of over there oh there's my knight he's almost ready by the way so let's see um you want to kick off with questions dude or sure I mean if we have a couple questions real quick maybe like five minutes of questions and then we'll get into actually building the game sure I see a question on your side oh look someone says can you link Charles's channel let me do I think Charles can do that right now it's the first question I'm gonna answer yes I can and then somebody asked about using scriptable objects as humble objects have you done that before I have not run into that use case sir I'm trying to figure out how to how to link this but using scriptable objects as humble objects no but I mean I don't see why you couldn't yeah I haven't done it myself either so I'm kind of curious um what that would look like I have a couple ideas but I have a feeling I'm picturing it wrong in my head I mean I don't know it's kind of a weird way to I guess word it you know like you could have like they're almost like they're mutually exclusive ideas like you just you could have a scriptable object and you know if you delegate enough to it and run unit tests a right unit test for the scriptable object then I guess technically it's the humble object pattern yeah I guess I think you're right I'm just not sure what the what the use is I think you're probably in the same boat exactly what the use case is I don't see let's see a couple other questions so ever mind going over ability effect system like you could find in an RPG I would definitely love yeah I've built a bunch of them they're really complicated though so it's something I don't think I do in the livestream but I might make a video on that just um and the whole idea is like making a system so that you can build out abilities or combat things that have multiple different effects and lots of things going on it doesn't make sense for most games to be honest like if you're building you know a first-person shooter or strategy game or basically anything that's not like a fantasy RPG with tons and tons of spells I don't think it makes a lot of sense but if you're building something like that you need a really complex system for that so you can kind of combine and create all that data and have it control your game but yeah I'll definitely do that I do like a super complicated one I think it'd be fun and I've built that many of them in the past and it's been a lot of fun gotten a lot better at it so I think I'd love to do that I always find that those types of things are kind of hard to run a tutorial for or create tutorial for because there really are specific to the game you know like even like even as something as simple with you think as an inventory maybe simples the wrong words something that you think could be genericized like an inventory system it's it's like I mean the inventory system for world of warcraft is dramatically different from the inventory system for something like minecraft you know you know conceptually it's like yeah I get an item I put it in my bag but you know how do you represent items are those items equippable are they you know usable they there's just so many different things that it's very hard to create one tutorial for all cases by the way someone was mentioning that my like my microphone was low I turned it up let me know in the chat if I need to keep raising the volume yeah I think you're totally right on that - like the inventory systems I've been trying to build some something similar recently and getting it super generic I think is it's almost futile it's it's not gonna work in your game generic you're gonna need to customize it so having a generic system to start can be ok but it's usually gonna I think shove you into problems but it's good thing to learn how to build and I think build a couple of them and see what it's like and see what the problems are like she said they'd come out totally different you could have slots with slot numbers you could have space and slot size where they take up you know a certain amount of area in a bag and you have to arrange them stacking limited inventory is like yeah things like that I'm actually building in that's why I bought it oh because I'm building an inventory right now specifically using the whole scriptable object workflow that Ryan Hipple you know that famous Ryan Hipple talk yeah yeah so I'm like I'm building one now and I'm like using only that workflow you know scriptable objects you know value objects and like game events the way he uses them a long time collections it's really cool but and it's kind of like again a mutually exclusive like the type of inventory I'm building I just happen to be modeling it after World of Warcraft because I put hundreds and hundreds and hundreds of hours into that game so I know that inventory inside and out but then I was thinking like well you know some of the problems I'm trying to solve for this probably don't even come up in a bunch of other games yeah they don't in most games that they yeah definitely most games cool you have to show that when you're done with it here is it for a project or that's for fun I could I mean maybe if we get some time I can pull it up yeah that would be cool I think that'd be a fun fun use time people might be interested if you guys are interested in seeing that just mention in the comments we can jump to it quicker somebody else asked do you have good uses for partial classes in unity no not really I think partial classes are the devil they're evil they were they were created for the sole intention of making WinForms packable with like with designers so the designer code could create stuff and not break your code partial classes really just hide big classes it's really just a way to take a big giant class and pretend that it's not big I mean it does I'll be honest it does make it a little bit easier because you can segment your code a tiny bit but it's worse than just using regions I think because it really hides the complexity and it hides how big things are it also makes it really hard to know why something is working that you're not expecting to work because you can't find it in the class and then you find out that there's this a little partial declaration of it somewhere else that's handling that one little part or something yeah I mean the the only use case personally that I've ever found it that I've ever found it acceptable is when you have some part of your framework or engine you're using generating code and you want to be able to edit that class that it generates um you know in a safe way because generated class is obviously a little get regenerated over on then you'll lose you'll lose anything you edit so yeah I think wind forms it's like that's the scenario it generates a wind forms class you can edit the partial and it can keep generating over and over as you edit the UI but you won't affect your your proprietary code yeah it just it tends to be a mess it's much better if you can keep the file small if you get to the point where you're thinking hey I want to make these partial it's there they're definitely better options and things that you could do you could look at just ways to refactor and separate that out think about how these could actually be separate classes because that class is probably doing way too much it's probably a little over complicated let's see what other things do we have can learn to publish game on Google Play step by step I'm not sure where a good place for that is now it's been a little while since I published a game out on Google Play I don't know if you've got any advice on that I I do not I haven't really messed around that to be honest it was pretty straightforward though just going through the Google I think I just used Google Docs last time just stepping through them it wasn't anything too complicated you build out the apk submit it with all the metadata the hardest part for me I think was getting the art in the right sizes yeah because I'm not an artist but yeah they have I think they have pretty good documentation on it was a lot harder getting on iOS just the documentation and the steps were kind of a pain but I think that's probably that must have changed by now I was fine with those things that it's like you'll learn it and then ones the next time you publish a game you know maybe a year if you're lucky you know if you really are all right maybe a couple months if you're really working hard and by that time things have changed you know there's certain pain points are always gonna be pain points I just said I just my suggestion would be if you're ready to publish the game you know start doing the research and figuring out what makes sense for you you know I think Jason and my chat said there was a udemy course or Skillshare courses but yeah it's just not something that unless you work for a company and that's your job playing like having that knowledge it's like it's like a one-off yeah it's not something you do often just like Steam deploying like I used to remember that you know back in my hand but I haven't pushed out of building steam in a while so I don't remember back and learn let's see a couple other questions and we'll get on to building the game so let's see hi c-sharp good for input handling in building games like sims and plan our c-sharp events good for input handling in games like Sims or planet coaster um yeah and I see sharp events tend to be a good way to handle input and responding to actions or things that have happened right I use events a lot it's very easy to get over complicated with events if you have events that are triggering other events that are triggering other events it's gonna get hard to follow the flow of the code but events tend to be a good way to UM to make it so that you can register for things in unrelated systems and get callbacks and updates on stuff like that try not to use them inside the same class or the same system as often though because that's when it tends to get over complicated for me and how often you use events Charles I mean I use them when I need them and sometimes it's a lot sometimes it's sparsely I think my biggest suggestion would be if you're using events because they can get complicated is to log a lot log everything and you know sometimes you'll ugh seems like you log too much say you wanna I guess do anything you can to mitigate scrolling blindness you know by having you know too many logs that look the same but ya know logging logging is key when it comes to all these events because you just need to be able to follow and it's very hard to follow along something if you just have no you know and no information to work with yeah it certainly can be a pain it is nice though when you look at the debug log in in your console you would be able to see the call stack of those events a lot of the time and see exactly where things came from but the problem I were in into too is like events that accidentally are triggering themselves or triggering another event that triggers the first one you end up with a weird infinite loop and unity crashes had that happen a couple times one of them was semi recent where I just as a side effect of naming variables too close to each other so called one event meant to call the other one and I was just calling the same one over and over and yeah blows up the editor everything crashes insects so eventually you catch it after like the third time like why is he keep crashing OH what other things I got how how to make a complex UI for shop missions and manage all the stuff in there that might update from one thing in the game to somewhere else like subway surfer oh this is a good question I think this is more about separation than anything right so if you have a complex UI that's managing this stuff you really don't want the UI to have much if any state or control or knowledge of the state you want to bind it up to the data that's actually kind of controlling your game so if you have your you know whatever your missions list stuff it should be pulling from mission list data that's the same data that your game is using and then using that to display it same with like coins or anything else like all of that stuff there shouldn't really be much logic in the UI other than selecting things what's available and that's about it and then the other code that's shared should be handling all of the what that data is and how it reacts to those things and how it does callbacks or Jason said something interesting huh Oh log each event as it comes okay you know so I'm bored with log and stuff you made a good point about having like an event dispatcher that way you have one place where you wrap your events through oh yeah that'll work great it makes it easier to follow but you know it's like you know anything in development you know readability you know being able to have someone else look at your codebase and have a good idea of what's going on and I think events I struggle with that because events really do kind of hide a lot of what what's going on and you really do have to follow things yeah yeah it certainly can make it harder to follow right but if it's done right and cleanly I think a lot of times it'll simplify and make things easier to understand if the events are set up right and the hooks are good is it's a lot easier to have like a data system that has a UI that's just listening to callbacks on something changing and it knowing about the UI and trying to call into the UI and all in like your data really that system is calling into all these other things they really shouldn't they should just be exposing when things change or when things happen that other things need to know about right okay a couple more questions can you do fixed when the fixed split windows instead of switching to them I would love to Martin but I have not figured out how the hell they get that to work in June I think we can work on that this week yeah the Docs that I found mentioned a bunch of buttons that I don't have and I don't know why so I don't know if they just haven't updated them or if I'm blind just probably the more likely option maybe I design some fancy like side by side we can put it in OBS or something oh there's like a 4x4 mode and that's like normally there by default when I talk to people it's fine whenever I hit the stream button it like disappears I don't know why and maybe it's the type of meeting I'm not sure I will figure it out for the next one though but yeah it would be nice to just be four by four or whatever and then have the desktop going to at the same time not a coder but I want to make unity games how should I start learning c-sharp separate from unity and after that literal unity or can I start with unity directly sorry Charles well I'm sorry what was that question it wants to know if you should start learning unity or c-sharp outside of unity and then learn unity or jump straight to unity and c-sharp well I mean it couldn't hurt to learn C sharp because it just a lot of it really depends you know I wouldn't say there's one right path I mean yeah if you learn c-sharp first I mean look if your goal is you want to make games for fun and you just want to get into it and you've got some ideas and you're like you're not you don't work for a company you're trying to you're not trying to find a job you could probably take a hybrid approach you know get unity try to play with it then learn a little bit of c-sharp try to answer questions to fill in gaps as you learn unity because learning unity means you're me when you learn unity you're learning a tool you know what I mean it's like an artist learning Photoshop you say oh should I learn Photoshop or should I learn you know color theory first well what are you trying to do so if you're just trying to learn programming and programming fundamentals and you never program in your life you know that's probably a healthy place to start well I want to make games you want to make games in particular I mean yeah I I would say learn some unity because if you're just if your goal is just to make games you definitely don't want to learn programming but you could theoretically pick up like a visual scripting suit tool or maybe if your game is you know simple enough it you know you could pick up some framework like I don't know what I don't really use any of them but there's there's like this one game maker I think is what it's called playmaker bullying my mother's yeah I would yeah you can get pretty far with those you can yeah I think he sounds like he wants to learn the hue I says I'm not a coder and I wanted to make games so yeah I that is an option definitely if you don't want to learn how to code you can go with the visual stuff if you do want to learn how to code though you I would say yeah just get into unity start building games the one downside to going out and learning a more academic c-sharp or like web-based stuff or Windows tools that you would build in c-sharp is that you're going to learn some things that are great patterns outside of game development that don't work well at all in game development and you're gonna probably focus on a couple things that are very different like if you're building web stuff you don't really think about garbage allocation if you're building a game garbage allocation is a big deal it's not a big deal when you start out but you can get into the pattern of not even thinking about it when you're doing web stuff and there are a lot of just I think patterns like that that really don't apply to game development that it's easy to learn and kind of fall into and it's also easy to try to figure I found a lot of people that know c-sharp they'll try to figure out how to do things that are already done in unity because they didn't start with unity so they don't know that a lot of systems exist and they try to rebuild the systems with the knowledge that they have of c-sharp so I would yeah probably just start building games go through some simple tutorials and then mix in some code tutorials to maybe grab a plural site course on c-sharp but I wouldn't do that first jump into unity build a little bit get familiar with it and then start wondering what things are wonder what the word class means why is it there what the hell is it go look it up and start figuring that out and then go on to why is this public what does that mean and start watching a bunch of videos on those as you come across problems I find it easier to retain if I'm working on a problem and minding the solution then if I'm just looking at a bunch of information that I'm not actually able to use building games makes it easy because you can use it share it and show everybody the thing that you built with it mm-hmm okay I'll take another question but I'm also gonna ask everybody to hit the like button one more time because we're only at 30 there's 130 people only at 10 come on either they don't fear the Lord or maybe you just need to get on to talking about game stuff I don't know yeah declaring events in an interface is that an anti-pattern no I do that occasionally declare events and interfaces not common but I definitely do it I don't know about you you ever put in events interface I honestly can't think of a single time I've done that but an anti-pattern I don't only think about like notify property changed you know true I notify property changes and I do things like that where I'll have events that have some sort of a callback that's enough you know or interfaces that have some sort of events callback yeah I'm super common though not like hundreds of them throughout the project but I can think of two or three in one project right now mm-hmm I saw a question on the chat but like Jason answered it oh good about component looks like about a UI stuff right I'm separating canvases out and a single wait and versus like co-routines and stuff but yeah what he said it's good can you make something like Age of Empires in unity you definitely could in fact one day I probably will build an RTS game when I get bored I mean when I get enough time to do it because I'd really love to make like a new command and conquer generals that's like thousand players or something I don't know I got like a million RTS ideas yeah it's definitely possible though you could do that you can make it an RTS in just about anything it just takes time and networking experience and yeah a lot of discipline I guess anything else for questions or I think you want to get off to building something let's do it let's build some so we were talking about building out a game oh you know what I wrote out in in my notebook let me see the name of that game I can find it okay so I wrote in another notebook Eve is in my notebook this is the problem that I have right like I like to write things down and notebooks but then when I can't find a notebook I just grab another one I like dude I would know what I would do without if I didn't have a notebook next to me at all times I just can't I'm constantly grabbing out new one tonight I just lose it which one I'm in so let's see did I write down the name of the game that I wanted to build well while he looks for that here's a book I'll recommend to everyone it's called starting to unit test not as hard as you think by Eric Dietrich Eric Dietrich is a really good blogger check out his blog and his book is really good and it's very light so you can you could probably get through this and like make you read it you can do it in one sitting I would think it's 100 it's less than 100 pages and there's not really exam I mean it's not really heavy so I donno recommendation for you game what's it called it's called starting to unit test not as hard as you think hi Eric yeah and it's not I like the title because I think people think that unit testing is hard and it's because in reality unit testing is hard if you try to just slap it into your existing project it's nearly impossible and it's nightmare and I don't know if you've ever tried to do that like take a 3-year old projects and slap unit tests on it even like a web project it's not an easy thing to do so it's unheard but if you're starting out new it's it's easy if started out with a clean project and it'll make things just better in general so I found the game it was called fill the line I'm gonna just post a link in chat and show like the the example and unless anybody has a much better idea I think this is the one that will just do a quick build out of and figure it out do you see it Charles I'm looking at him now oh you've pasted it in chat so you drag a line here let me I'll screen share okay there and we're gonna share this main screen there so I don't know if you guys can all see oh look I see a side-by-side now see what zoom looks like okay so in zoom you can see it here's the game it's very simple take this you drag and you get to the end like I wanted oh right but it gets more and more complicated right so you go around corners it's slightly more complicated and eventually you get to parts where you're wrapping over and you didn't make it and the levels are pretty complicated let's go to one of the further ones so I went through and played this a couple times to try to get an idea of how it plays and what it's like and it's got all kinds of crazy things once you get further along like I don't know how you beat this one oh I definitely can't do it that way it's gonna be like that no oh yeah see I messed it all up so well you get the idea like you have to go through and build the line you can't go back on or you can go back but you can't go like back over a previous one like I can't cross over this and it you know you fill out a an area like like if I do this I'm screwed because I can never get into there so it's not a super complicated game I think there are a bunch of different ways that we could implement it I don't know what you what you've got in mind does anybody have any other suggestion real quick before we do this or any reason we jump to something else because if not I think this is a fun one to do what do you think Charles that looks fun I mean it's interesting because I was just noticing that you can actually beat the same level multiple ways yes I think there are gonna be on a lot of levels that are probably multiple ways to beat them anything good that's more the case as your earlier on to like see pick like a medium one that's not super hard and not super easy like your level 10 so here you go like you can only go around that way otherwise you wouldn't make it alright maybe you can go this way too oh yeah you could also go this way nothing really stopping it from from going that way so I guess I just kick up a new project so I made an empty project it's still in a beta version I haven't updated this version but I don't think it's gonna be an issue and I figured we just start coding along and I want to use a high definition render pipeline for this HDR P yeah hopefully everybody can see everything is that does everything look okay on the screen there and YouTube yeah it looks good I mean you got a big not too small that there's a big dark section on the right that might be bad so is my inspector cab so for some reason it's just an issue with this beta I've have had where the tab like disappears and then this black area appears I don't know it's it's a new issue with this version of the beta okay somebody else said it was too small let me see if I can change my display settings real quick I'm just as can I resident on to UM to 1080 what was that someone had said that can you add some 3d flate or flavor to this oh I'm possibly lay down the groundwork and then and then use three models after we got the basics yeah we could do that be interesting all right so we've got is this better can you see it a little bit bigger I changed 1080p it's gonna be better than personalist is perfect that's a good sign great all right um okay I guess idea so how do you want to start again I guess like what I was thinking is there a couple different ways that we could handle the data for this we could either build out some sort of a 2d map of like all of the available spots and whether you're there or not we could also just slap out cubes and check the distance if it's not further than a meter away and you haven't touched it before it's valid too or I don't know it seemed like there are probably a lot of options it's like implicit versat at first is explicit you can explicitly define what your board is or you could just implicitly just by virtue of you know where you place the blocks and it checking in real time you know to know if if you CrossFit's cost over itself or if all the blocks had been filled in yeah and I intentionally didn't think too much about the options so that this would be hard not to think too much about what we could do or what we should do or ways to do it because this is kind of thing that would normally happen when come up with the problem and then think about what our options are maybe even do a little research on possible options um yeah I feel like and I always like to start with the data structure first and I just imagine like off the top of my head I guess I'm just I guess no idea stupid so I'm just gonna say this maybe you have like a - like a 2d array to represent the board and then every time the line enters into that space you can enter increment a number so let's say it's an int array is what I'm going to say so you increment so if it goes over one space would be one and then if it ever goes greater than one you know you know that it's not filled all right still use bullets to write like honorable and only allow you to go to ones that are off yeah that's true that's true too let's just let's start I like to start with a with a data you know the data first and then try to like put it out until a log and then and then work on the UI afterwards or like the visual representation of it okay just call it game board for now for the data structure yeah seems like a good one um somebody asked if there was a reason we were using this specific beta version no it's just the beta version that I happened to have installed so been using this beta version for some other stuff there might be an update available there probably is it's yeah the only reason was I'm trying to get used to the new UI get really comfortable with it and just I also kind of like some of the features in the in the new editor it seems faster snappier and kind of cool and yeah the most I gotten used to the new UI all right let's pull over writer here so anybody that's not using writer by the way it's just a No code editor it works same as Visual Studio I just like it a little bit better because it gives me tips and hints and makes me slightly better coder and I feel like it's a little faster and easier to use I also love Visual Studio so I use it outside of this all the time for other stuff but that light thing we're on that okay so our game board may or may not be a monobehaviour I'll make it not amount of behavior for now because we don't know that it needs to be and get lots of zoom ticks here nice nice nice and willing an array events or area bulls mm-hm double array like a yeah basically the game board we're just encapsulate you know moving through the positions on that but the idea so it would encapsulate keeping track of yes anyone is current and because that's a thing we need right we need like the current position mm-hmm sounds about right ideas obviously you're not gonna stay as public badly named variables but I want to give them something right now so we need to keep track of like the current position which would just be an X and a Y and then all of the available positions and anything else well we don't know this is gonna be a mono behavior or not but I reckon a we call it a constructor to create the array based on the sizes you passed in should we do that or should we do like a factory that generate these things you do that yeah factory be nice let's try one line of code and I learned a new thing some people had never seen a double boo boo array oh yeah double array so you get the first index and second index okay so game board factory would have like a public static and board and then give it and um so this is not gonna give us custom fancy boards it's just gonna give us where boards for now I think that's a good place to start though yeah and we do like uh maybe I should just maybe a constructor is the way cuz more thinking about this yes yeah let's change it let's it's a seat or and cab by the way if you wanted to keep those private you know you could just have the factory be a subclass of game board and then it would have access I think to the to the private variables yeah I was just thinking more that um we're not using the factory to do anything other than make a two by two array so it might be overkill gosh um okay I have a default dev like a we should make factory for this thing and like maybe we shouldn't you've broken the first rule don't overcomplicate things so set our size x and y then we'll initialize positions you pool array of size X do we want to do width and then height yes X and then height yes rose why did I make this foot size rows and columns oh yeah yeah I like that more so this B current column row there we go mm-hmm wait what's the problem here oh wait oh wait a minute what am I missing yeah I don't know what happened I almost never used double that should be fine maybe maybe were just taken wait mouse-over let's see what what he has to say expected oh is it comma yeah oops no I don't think it is a commie I'm trying to America it has been way too long it'll be let me Google that how to initialize it this is exactly what I mean right like things that you forget I have not designed this multi-dimensional raise so I've done the other ones to you or you like a comma there oh look at this so yeah like that's think that way but I've done the ones with two brackets I just don't remember how I did them I feel like I have to maybe that would see what someone says one is an array of arrays and the other is a 2d array that's what it was oh okay we were creating an array of arrays that makes sense so okay and then this is the multi-dimensional right much better thank you again kind of stuff happens all the time okay so here we go we got a multi-dimensional array of pools in a game board that we will create alright so if we create it like this like our first game board creator let's see how do we want to do that so I like the first thing I want to do is just create like a game board that's maybe like two by two got it so that we just do because I think the line one is really boring goodbye to a 2x2 board and then we need to represent it visually and create it so make a monobehaviour that just creates a game board for now yeah sounds good to me game board creator nice it's my test class to make up game board so do like a on enable columns due to columns and rows that's a good question I think we did yeah we did columns or rows okay so this would be like I'm just gonna set these two two again you're making them public because this is a little throwaway class these will get renamed if we actually decide to keep any of this but I think right now just use two by two we'll create a new game board and then make that game board visible somehow yeah so now though that'll be the challenge displaying and now we need to bind it up to something that can render it well first let's move the game board creator into its own file alt enter by the way so you just select for the class anybody who didn't see that you just go on at select class hit alt enter and there's a move to type if you're already in there and it's a different class than the file name so just moved it right over to its own class so this is gonna make my game board and then we want to yeah I do something in in here to actually show the game board and render it now so I think we need some sort of a view layer I don't know if we want to do this in UI or three deme I guess we talked about doing it maybe adding a 3d component so we just build it as a 3d game instead of A to D UI one just in case we decided to go with that route select the main camera I'm just gonna reset the camera over to zero raise it up a little bit on the Y and then point it down which you think is what ninety on the X you could like genericized by having an interface called game board drawer and however it decides to draw it yeah I think we're gonna have to do something like that let's see I'll just make a empty cube at 0-0 real quick and look at the game view and then actually here let's play side by side so I was thinking and Charles let me know if you got another ideas or better way to do this but we're thinking is we could just set up some class that is responsible for just spawning a prefab at each of those positions and then rendering that thing basically a prefab or a cube that's mapped straight over to our data structure so a position on the board so when that position on the board changes or the cube changes or when the cube sends the cube maybe is I guess the cube is getting the input and then sending something to the game again the cube the cube technically represents would represent like a space that is accessible I guess you know where you could draw a line yeah and then so you know when and it could be anything I mean it could be a cube it could be you know like you said if we use a UI but whenever it receives the input that we'd expect I imagine it would send a signal down to the game board the actual data structure to notify it hey look I'm moving to this location it seems right all right so let's get the view set up some sort of a game view that just draws it well first let's see let's move this stuff around so I'm gonna take the camera here and just pull it up go up to like 10 meters and set this to a solid color clear and just make it like black so that it looks cool right and then the other thing I want to show real quick before we go into the code is by duplicate this cube and move it over see how if we get the perspective change so to go to the camera and change that to orthographic so they look nice and flat so yeah I was thinking to make a class like a what do you want to call it to render the game board yeah I mean I think Wow can't game game board view so far to us in like a like a game board view I don't know our game menu game board drawer I don't know that's like some unity property drawer drawer or it does kind of sound like a pop property jar or drawer oh okay um so here like game board this is really just like a binding command so we need some some way to when we create a game board bind to that game board up to the view okay so I think the game board creator could just call create a game board and then pass it into the view for now yeah I mean I've been what I've been doing lately is instead of said doing a bunch of setters and getters on mano behaviors I've just been more comfortable leveraging the attaching them to the same game object and I'm calling getcomponent I mean we can do whatever but I don't buy this one's not uh-oh the gain tall you're at the game board it's not because it's gonna change every time we generate a new one yep if we want to dynamically don't or we haven't yeah but yeah I know totally every I get component all the time just in a wake the only time I don't do it is on things that have to get nude up all the time throughout the project so we're not generating but we're allocating a bunch of stuff or making getcomponent calls run and do them all in awake but yeah I totally agree there so we set a game board and do like game board like that and generate a field for it so this will be our reference to our game board and then oh let's see do we need anything this shouldn't be fella right we probably don't need anything in an update yeah what I was thinking is we were talking about events maybe we should just have an event in the game board that calls back when a thing chain well actually not list a friend her first right before anything else let's just do them dry since Co get the game board we need to instantiate the prefabs so I think what I was going to do is just make a prefab field where we can just put in a cube have it spawned them all out yep I'm all about it so to add a serialized field would be a private game object cube prefab and then in here we'll loop through the game board so say like for each column in oh no we need to do a loop right and do a for loop is zero to game board dot we don't have a.m. we don't have those exposed Yeah right I was wondering about that like okay yeah we can do that so it's pulling the scale takes a couple so to do that we just add a public in two columns with a getter and a private setter you know I'd pretty sure with alt enter you can go to uh nevermind I'm done yeah you're good oh wait we do this right generate introduced a get only auto property for rows watch this yes okay I'm not dumb okay all right yeah that's the way that I should have done it shortcuts shortcuts their King their fix that one so now these are set up as getters only so they can only be set in the constructor fact we can make them read-only they definitely can't oh wait then they have to be fields no that's fine because it's just a getter you you'd make the the ones below oh wait no I think I want to do like this so that they are public fields but they're read-only they can only change in the constructor and it was only thinking because that actually makes sense for this scenario right like in this case we literally only ever want those to change in the constructor so making them public read-only feel to work yeah make sense and it's more explicit to cuz if you make it a property with just two getter I don't know I think it's more I think it's more exclusive to say hey look these are read-only properties yeah it's definitely less ambiguous because our reader or a getter only property could be anywhere but read-only feel like this means it's definitely set in the constructor I'm gonna move these all up by the way so it's just alt shift and just move these things up here somewhere that's another one that end up in the right order and get rid of all using statements because we don't really need a bunch of extra junk in the code okay that looks good we're still not using these so I'm gonna ignore them for now so it loop through game board columns and maybe I should rename this to like column and then for each row or for the rows will do int row game board rows so that's gonna give us a loop through all of the columns and all the rows then we just need to create a cube the game somebody asked what game we're making - it's this weird little what's it called fill the line game so just look it up you see it that's what we're gonna build out so next step instantiate the prefab yep and I guess in this case this was like a primitive sort of case we're just gonna put it at the world position based on the column and row oh yeah I actually makes a lot of sense make it nice and we can always offset that yeah you doing instantiate of the cube prefab give it a position so give it like a all right here actually let's pull that part out just do the position bar position equals new vector3 and we're gonna give it column comma whoops no call zero comma row that right yeah I think so I think so I know the middle one would be yeah why up and down in the world space and we need to give it a quant or neon actually know what I want to do is set this as oh wait no you think I want to instantiate it as a child of this I think then I'll just set the position is there an overload for that there's so many instantiate overload area so you got so if you just do the you can do the position and a quaternion but I want it I want the parenting first because I want these to all be children of the view got it yeah um yeah but I don't think they have one over little for that one all good set the position and then I guess I don't need this you know variable there to use two lines later okay so that should spawn so we set a game board spawn a bunch of things that's it it's a yeah it looks go back over here actually set it up and test it out real quick I thought lights turned off why'd that happen someone says you can pass a third argument as the parent and lift that up can you pass that with a position though cuz I feel like you you know you should be able to I would think so but there are so many overloads I've lost track all right so entering this cube into a prefab yeah well it's gonna be the prefab position quaternion and then finally the last ones the parent okay try that well and also oh you have to tell ya the position fun fact oh you can do that too you could there's a shortcut ctrl alt V it'll actually introduce a variable oh yeah interesting I don't think I've tried that one before alright so now we're instantiating it in one call even better so tiny performance improvement and then let's see what we need to make prefab create a folder prefabs and just take our beautiful cube and drop it into there then we make a game object for our what did we call that thing the something since Bob or view or I think or creator that we need both game or creator and a game board view and I sign the scripts signed and signed and then we got to set up that uh the cube prefab here so go down to prefabs and assign the cube prefab and if I save my scene yeah the Creator calling a game board view it is not play nothing compiler error maybe let's see let's see if I can build real quick make sure there is gone yeah just yeah okay cool so a set game board actually needs to get called by the Creator somebody was talking about I'm using bar I see I know I don't like to use what do you are you you like to be explicit it depends I use bar on things like if we go back over here like position I know it's a vector through like it's named position it's right there it's fine and the instance of the game object in the cases where I know the type and it's really obvious I use bar when it's not obvious then I am then I switch to the variable name as soon as soon as I like can't look at it and just know then I'll switch the variable type unless the variable type some obscenely long thing you know 30-plus characters long all right so set game board needs to get called by the game board creator so create it we'll just find it for now ah that's wrong game board scared of that extra using statement - okay so there we go that should find it and set the board whenever we reenable the board creator by the way I like to use on enable for these just so I can toggle the thing on and off and run the code a bunch time nice let's just flip that on enough I also get used to like projects we're starting up sometimes takes a long time so being able to just toggle a game object on an off to run code makes it easy let's hit play and okay well something happened right so game board view ran we got some cubes think it worked it did not like square does it just looks like a big oh yeah I see so if I disable a cube I'll be right back I had to take a quick phone call yeah go ahead so yeah it looks like it's all working right we've got our four cubes here I could change the color of them or something and see that they're all different but we've got the four basic empty cubes there right minis bar for loops just because int and bar are the same length so using int just yeah there's no benefit plus if I type 4 and hit tab it's gonna auto to pick int so I don't have to type that out no reason for me to go back and change it make it less obvious so yeah I think we've got the view set up and the next parts gonna be reading inputs and sending that data back down over here let's play with that create a real quick right so if I change the creator and make this like five rows and three columns and hit play we should see the same result there we go p.m. but we could definitely do an outline around them or something it's just that in the actual game that we're cloning that's not really how they are they're more like this - these gray areas and then we're clicking through and infilling them out in fact perhaps I should change it so that the background is white and that these are gray let's let's reload this one more time so I think that would help let's play I'm gonna get back in but yeah I think white white backgrounds and and gray inside let's see let's try like level 9 yeah so let's go for that let's go for a white on the back and this light gray in the front I'll make these changes right now so take the gray or here let's take the main camera background - solid white I'll look at that we can see a little outline there of our cube and then I'll take the cube and let's gotta go select it and oh we need to make a material for it so go in create a folder for art I'm not gonna have my chart so I'm just gonna put the material right here you know just create a new empty material and call this cube and we'll assign that to our cube just drop it right on where's our renderer mesh renderer materials there we go like blind today so anyway sign it to there then we can expand it out and change the color to be more of that gray there we go and let's apply that prefab change let's go up to overrides and just hit apply off so it updates our prefab hit play one more time and we should see cubes that look a little bit more like that there we go not bad now the other thing that they did was they were starting off with a cube enabled right so that it was green and selected I don't know if we should start there or if we should just jump over to being able to open and select stuff um let's see oh just looking any other questions to use it for chunk loading I'm not really it would you need to load in chunks stuff and slightly different what you want to do them all asynchronously and stuff or there are other questions real quick following tutorial sirs creators into nested if statements three levels of nesting okay that's what the discussions about yeah nested if statements tend to be careful they tend to be like an easy way to solve a problem immediately but then it turns into a bit of a mess and gets very very hard to follow later and really easy to break things um I'd try to minimize your nesting of things see anything else yeah the camera could find the center point of the grid somebody to mention that so we'll do that later or just move the camera over and then I think that's it so I'm just gonna jump back into coding unless people pop up more questions so we've got the board here and the next thing we need to do is read some sort of input here let's hit play again it looks like but we need to read some sort of input and look for me holding down the button and what cube I'm on and then we need to send that to something so let's make a um let's make a little game controller I don't know exactly what I want this to do and how I want to architect it out so we start with something simple like a game controller and then we can split out the functionality from that as we go along by the way everybody is still watching if you're still watching you don't mind hitting the like button and sharing that would be super helpful just gets it out there for more people and more people join and we get to do more cool fun stuff alright so we've got a game controller and in here I lied about the name I think this is really gonna be starting off as like an input controller so let's make that explicitly private and then let's do something to read the input so say like if input Mouse but get mouse button to get mouse button 0 so this is whether or not we're holding down the left mouse button so if we are holding down the mouse button try select new cube or try move to new cube let's try that I think that'll be my name name for the method so let's hit enter and create a method for that and next thing I want to do is just figure out what cube that I'm on it is default to private somebody asks the method here when it's like that is defaulted to private I just have a habit of making them say private so that when they're all collapsed they line up nice and neatly drives me nuts when they don't line up now it didn't used to ice and I do that at all but now I'm weird and I just do it every time so they line up hey what's up Charles you're muted but welcome back hey thanks for let me know talk like that's very interesting tell us Martha that's funny so setting up a game controller Charles they answer to answer a couple quick questions and it's setting up a game controller to read input and then try to enable a cube so we're singing those I'll just do a recast from the camera shoot in see if we find a cube and then see what what position that thing is associated with although we don't have any of that information yet so already so I think would be like a Ray Ray Lewis camera and I'm gonna do something dirty here main camera that mean the screen point to Ray so if you use camera dot main like don't use it for real we're just using it temporarily because it finds the thing by tag every time you do it so we're gonna cash we're gonna use the camera we're going to get position of vector to zero and the reason for that or sorry vector 2.1 / - that's right active so what we're doing there is just getting a ray into the screen from the center of the screen so when you pass in screen point to Ray it's zero to one it's like from the bottom to top and left to right so if we go Oh point five point five it's right in the center so we just do a rake a straight in the center camera that mean it's beautiful will cash that later in fact we could even we could do something like had an awake or an on and able and just do camera equals find object to type and we just find the only camera that we're gonna have there let's do that let's let's pretend that we're keeping things somewhat clean there we go if no camera dot mean so we'll find the one camera right when we enable our controller and we'll use that now normally we should have some sort of a camera controller or something to manage all this but we're only gonna have one scene I think so do a ray cast and then or we'll get a ray then do a ray cast to do if physics ray cast and we give it our ray out this part of love by the way ray cast hit hit info and max distance really I don't even care about a max distance if we were we don't have any background right we don't have anything go back again so we just want to get the first thing I love that we can declare the type though here in the outs not having to do that aligned before and initialize it so then we want to get the cube so it's a hit info dot get comfort Collider get component and we want to get something for our game piece we don't really have anything like a script on there so I think maybe we should just create one I call this like a game cube and we'll call that var game cube equals that so we'll need to create a component for gamecube does that make sense to you Charles he's making a component I was thinking this could just have its position on it basically yeah it's gonna have it it's it's X and it's Y as variables instead of using the transform position in the world because it seems dirty so yeah I'll generate a type for it and we'll make it a model behavior and I'll make that public I feel like we'll have we'll do some renaming later but yeah the idea is good game cubes perfect name and oh yeah right nes so for this we'll have a public float no int row with the getter and a column and then um public void like we want to do just I can initialize to set these move that only sets them if they're not set yeah right here let's let's do an initialized variable mm-hmm invalid operation exception now normally I wouldn't just go around throwing exceptions in here but it's just gonna log out in there or if we screw it up generally throwing an exception not something I would necessarily probably just do a log or something but here it's gonna throw and just put an arrow right in there and say hey stop being stupid I think it's not a warning or something yeah well in this case yeah it probably should just be you already do this let's do what I would really do right we would log in there tried to initialize game cube and give it like a game object name by the way the dollar sign here makes it so we can put the little brackets and start filling things in at string interpolation key someone bro it's cold column it was already set to row comma column there we go I don't know whoops that formatted right but was first let's fix the spelling I am i TI a li Zi there we go so it'll just say that we tried to initialize the cube give us the name of the cube if we happen to put a name there the new the position we try to go and then the position it was that and then we'll return sure that shouldn't happen but if we screw up and we try to initialize something that's already initialized we'll get that problem okay the next thing we do is just say Rho equals row column equals column and we're done it wants to know that that pattern I guess if you will can loosely call it a pattern it's called the guard Clause having a statement that short-circuits your your method oh yes yes at the top or you just check in bailout log an error or something else um private setters get add some private sale yep yeah thank you do you have to make the set of all there we go so I think that's good let's move this to its own file so again anybody who's not doing this normally just select the class hit alt enter and hit move to type i remove type to file I just move it right over so now we've got a GameCube initialize go back over to that game board view because the game board view is what creates the cubes and here would say instance dot initialize oh wait we're not initializing it as a game cube there so we need to change this prefab type first hmm there we go then we can give it our row and column nice although or we did we do column and row on everything else first okay we did columns and then row so let's go into here and watch this what is it control shift our change signature but just to select my row and hit move down next magic the joy of writer just rearranged my variables because it also rearranged them here that's like that's why it's good because it fixed all the calls to it you so now they all right so we're initializing the Gamecube our game board view is set up okay we were gonna do the game controller so now that we can get a Gamecube out of it we just get those positions and set something on it I almost feel like like the Gamecube should be responsible for telling us whether or not it's valid or whether or not it's already set I don't know maybe no and now I don't feel like that I thought I felt like that for a second let's see so our game controller I think that our game controller needs a reference to the game board that makes sense let me see on the catch up here I say so you try to move to the new cube so the whole goal was hold down the mouse button try to move to a new cube so we can figure out what cube is there but then we need to link that to the game board data and get the state of that position yeah I think at the end of the day the game board yeah is the is the object that knows the state so so I was thinking is like right now our game board it sets the game board on the view maybe I should set it on the game controller and then the game will the view should just look at the controller make more than CA let's try that should be like a game controller sighs so this would be a game controller and then we'd make set game board there would you just do that get rid of all the extra code anybody who hasn't used these by the way they're just expression body methods so it's just a simple setter we can use the lambda here and then put the one line of code that it's going to do since it's just setting it's fine so we'll set the game board there and then the game board view oh maybe this is a good time to use events all right the game board view could just listen for the game board updating and then update update it's uh spaces accordingly yeah I think so that make sense I see my good idea so the game board view right now is only responsible for basically drawing a representation of the game board in the scene yes well it's really for handling those cube prefabs right so it's spawning them and then those things are able to be collided with with the simple ray cast so it has a reference to a game board so basically when things happen on the B I don't think it even needs a reference to the game board though right it doesn't maybe at this point well I mean at this point all it's responsible for is just drawing it initially yeah it's really like a game board spawner yeah which and when you think about spawner like I mean technically the game board is spawned in memory but this is responsible for spawning it's its representation and in this case it's its representation is it just built a bunch of cubes so technically it could mean it could draw it isn't any way we want I mean we could draw it in the console or we could draw it in the you know draw it with with the UI but I think right now it's just putting these cubes in in space yeah all right so I want to rename this game board I mean I want to change it again I think but I think that seems ok so ok if we go this route then the game controller should find the camera it should we don't necessarily need a game board creator anymore this was initially going to be a temporary class but I also don't want to put rows and columns into game controller so maybe I'll keep this around for now yeah if you think about a game controller you know oh well yeah never mind I was gonna say game controller fundamentally controls the game so you know maybe it should have access to the columns and rows for this particular game it should be getting that from somewhere else right let's maybe make a scriptable object yeah maybe give it a set of scriptable objects calling data things or level I mean cuz you know if you think about it it's the level is the one who knows done each level has a different set of rows and columns and you know it has a whole board you know if you put two do : in front of a comment like that yeah right or treats it or something if you down here yeah yeah tip for you guys don't a writer power user in the to-do list yeah I think that's a good idea that I think we'll keep going build it and then turn this into some sort of level scriptable object or data structure or something it seems right anybody mentioned public is for more than the inspector yeah public is for accessing things outside of the code and generally bad that's one of the reasons that these need to change that these should be serialized fields that are private ooh another fun tip I think it's a s if you type s prop that's a that's a live template for serialize fields okay that's what that s field right now hit tab yeah int and then tab that's not bad that's a new one for me alright I'm learning new things and then s prop will make a serious serialized field that acts as a backing property for for private field that's problem Wow that is beautiful alright I'm learning more shortcuts I love it don't forget to hit like for Charles of shortcuts on my video not is don't don't hit it on his okay let's see so we've got the game controller and the game controller getting enabled is now going to call the game board creator and just say get a game board and we'll make this return a game board it will make it public so we'll do this it'll just generate that and we won't do that return game board so this would be like a level or a level of generator eventually I got another another little shortcut for you now I think this might work but but I it seems like you're using Visual Studio shortcuts for your for your writer I don't know if you set that up Ida left it as a default writer one so I could get you a stone if you go to back over to that class I think it was the game board creator yes and you put your caret anywhere in the word game board on that return this one yeah and if you hit ctrl alt n it should create an inline it should inline it it did not ctrl alt and no didn't turn yeah I don't know what my settings are I thought I had it - OH minor is IntelliJ that's what it is Oh Java because we could just return back that new game board yeah yeah I use it I use that one all I use control-v and controlled end all the time to inline and then create and introduce variables now it's just to a tiny little expression oh wow writer so this is again when people ask why I use writer it's because it just kinda reminds me to do things like this and shorten up the code and get rid of a bunch of extra nonsense all right so let's go back to the game controller so game controller hits we enable we need to get the game board creator so say like let's let's have no wake here because what we'd really do is cash all this kind of crap and awake so move that up here and we'll go game for creator let's find out your type and then in on and able and actually create a board just say like game board creator dot get game board okay now we don't need a set game board method anymore that's already being done I am delete that and then we just have to call into the UI so find that game board view get the game board view right here and generate a field for that and then we can just set the or what do we call it I forgot the name because the downside to rename anything straw game door or not drugging booyah okay so now we'll create a board our game controller should have it and then tell our view to draw it let's try that all right here we can start reading him oh I changed the colors by the way it'll get in a way when I change this she's trying to blame me oh I was trying to match the actual game oh we need a game controller let's create a controller somebody asked why I put underscores there you want to tell him why Charles go back what why I put underscores in the code for the for the field names yeah I so basically for private member variables you preface you prefix your variable names with an underscore this is this is not a hard fast rule this is just general generally accepted syntax so for private member variables I mean I personally always put an underscore before the variable name for public member variables I make them Pascal case which is capitalized the first level capitalized and the rest is camel case I don't know how to describe it pesco I do the same and it's same reason it's just to make it obvious that those are private member variables and that they're not parameters or something else yeah Pascal case is basically standard naming but you every word you capitalized so it's not just like you capitalize the first letter you capitalize every word and then camel case is same but the first letters lowercase I did not add the cube script to our cube so getting errors so I was gonna do is add that real quick I just someone asked what a what a member variable is just answer that since it's related a member variable is a variable that's associated with that with the class so like if he has the class game board then the row and in variables are member variables they're part of that class as opposed to being a variable of some other class there's something else I was gonna say Oh on the same vein of naming things what something that I've been doing recently oh can hear me I need to apply my prefab oh I'm sitting here coding along while you're talking and it's not working I didn't it apply on the prefab happens all the time I was about to start debugging go ahead keep on yeah someone just put M underscore I ha ha gosh that's such a pet peeve of mine I never used that but what I what I was gonna say is that something I've recently started to do is for serialized fields that are private I'll nix the underscore so I'll just do camel case just something I've been doing with mono and that's only in mono behaviors obviously and only for first as fields and I don't know I kind of like it for me personally it is a solid indicator that's something that I'm a variable that I'm referencing is private but accessible in the editor I think my writer writer even like what Kat will make it bold if you get rid of the underscore oh nice yeah for awhile I got rid of the underscores completely and just used tooling to help with that but then the problem that I ran into was that everybody else on the team isn't gonna do it but I've tried you're not gonna get everybody on the team to install special tooling so unless like the default tooling does it it makes it obvious just going around putting it in the code if there's no tooling in place and all but I think all bets are off I think I'm just gonna well I mean if there's no special - like if everybody is using writer awesome but a lot of projects to work on like people are using monodevelop or Visual Studio or other stuff and getting them to do plugins that do stuff and make it work right it's just not possible I've tried so I ended up going back to underscores and again it's just literally so that you can tell the difference between between the I forgot what I was gonna say the private member's like like Charles is saying and like local variables or parameters that come in and somebody else is mentioned the M underscore stuff again hey I think the Emma was supposed to be an indicator that there was a member variable and there would be like I underscore for integers some people would do it and I think the initial idea was supposed to be that they were supposed to be named for things not the type but like the thing like T was supposed to be for timers and C was for counts and stuff I just hate it because it's it's it's extra stuff that you have to type for no reason like I don't need an M underscore to know that it's a member underscore is enough for me and then naming variables good enough tends to get around needing to put in the extra type stuff there I'm gonna stop babbling on about that though cuz there's another issue here that my codes not working oh wait I just wanted to say well maybe want you to book that and I hope you in a second it Jason other Jason what other Jason would have liked what do you want to be called a piece of fruit he's like it seems to be a call-in show something he had said is like you know basically anything you add to your code is information you know I mean you don't write code for the computer you write it for your you know yourself well we write we write code the way we do for ourselves so we can read it so I mean yeah if the team you're on is like hey look I'm my eyes are really used to the M underscore well then that in that additional information is gonna be valuable to that particular team but you know and you really think fundamentally about the whole hey why do you put an underscore for private member variables it really is just to to in the simplest way articulate to the reader that this is a private member variable which may not be obvious if you're a hundred lines deep and you can't see the private member variables you know on the on the screen because you know if you have a local variable then it's not gonna have an underscore so if you have two variables next to each other and you don't have an underscore for either then you're you're really not gonna be able to tell but again really you know I don't know there's the argument you can say to each their own but I think there are some things that you know are really are fundamentally valuable and I personally think that that's that's one of them I agree that's my rant I'm doing good coding standards and naming is super important and it gets undervalued and under look a lot so 100 percent on there so I'm looking at my little LEDs lighting up over here every time I move there's no setup for that emotion sensor in that dude I got the I don't know if you can hear the little lights pop on can you see it on the screen kind of it's I can't get it to light up now I can't move in front of it move these things are neat but there we go it lit up I don't know what went down and I got a little speaker set up but it's it's distracting Oh lighten up in my face okay let's get back on - uh I'm Dakota I guess those exceptions you have they look to be like these are all just editor problems with the beta yeah the code actually worked once I hit play and built I think I hadn't built before so if I play I get a 2 by 2 cube everything I think kind of works oops if I modify the creator 4 by 2 we should get the cubes let's see okay so the next step was going into our game controller right here next step is cleaning up this code because we're already there and it's messy now the next step is going into our game controller and trying to move so we'd get a cube if we hit 1 and the next thing we need to do is I don't know check with our game board and see this state yeah so all right where we at here sorry so the game controller has pretty much you screw up a little bit there yeah let's hear let's do it sooo mout real quick first so you can see the entirety of the code you double-click on the tab to it'll jet it'll make it fullscreen or it'll it'll minimize all the other windows get rid of all the other stuff ok alright cool so the game controller it's doing what we think it should it's controlling the game here sets the board draws it capture couple things mm-hmm on enable we get a new board and we draw the board and then in update we're gonna do a try move so I think we need to read something from the game board to see if the position it or if the current spot or if that spot is open in fact I feel like thinking about this more we look at our game board mm-hmm these two fields that we didn't actually use probably don't belong here I don't know what you think the current row and column well all right so the game when we were showcasing the game earlier we're playing it it was you click and you drag right and that's how that's how it picks up the thing ok right so you click here and you start dragging and that lights them up so let's see if we can get as far as lighting some up so the simplest case I'm not quite sure if we're gonna need those yet but uh let's start with the simplest let's see let's see if we can just light one up and then go from there there's two like a gamecube dot you come in abled or enable or light up like God let's see would it be enables I think I'm filled because it's supposed to be a fill the lion right yeah but and that is one that isn't that that's only one representation why I had the microphone in my face Besant that is only one wreck that's one representation so what is the fundamental what are we doing we're I mean we're carrying a grain we're turning a green and marking it as it's been filled like the spot has been used okay okay I guess we'll just call dot fill I guess unless that's taken probably not all right so we're gonna fill it so do renderer Tyrael color equals bell color none of those exist so let's generate alt enter create a field call this renderer or type of renderer and we'll add an awake get component render so we're just gonna get that little cube mesh renderer i'm generate a fill color and we'll make that serialized and set it to you green I've got another writer tip if you go to the top of your class there you can type wreck wreck comp and that'll be another live template for required component Oh what Q are req got it okay nice I do have a video on that if anyone's interested it's up Devon that is nice okay cool so we fill it we set it to that and it's not clear yeah like that feeling clear so the important things so far to note is that right now all this GameCube class is responsible for doing is just representing that an areas filled fundamentally nothing's actually happening to our data object right which in here I'm just catching the initial color in a wake so we have a clear method that can reset back to whatever that initial color is and not have to have it as a separate field too easier if the designers can just go in and change it so I got a fill and a clear clear it's not used yet and we have an unused system statement all right so is that it that's it huh that should allow us to at least hold down and turn the green or turn the cube screen let's see you nope so what's happening why is this not working let's see nothing's happening at all you working on a game controller go back into our game controller and figure out why it's not working so I don't know what you normally do here but my default is to just draw the Ray real quick okay I would have been logging every step of the way approach dimensions like I would have logged every inch of that code four percent of my codes logs oh and then you have to go back and delete all the logs later oh man I don't delete my logs of it then they kill you eventually they kill things okay so the Ray is way the hell off why is it okay let's see let's go to the mean it's nowhere near the main camera okay the Ray is always at zero zero zero so there's an issue here I must have missed something so you're casting a ray from the camera just Casa for can you catch a castaway down from your mouse yeah that's what oh wait yeah sorry yeah you've been working with first-person controllers too long man yeah I don't want to shoot down in the center of the screen I want to shoot down at the mouse position I would have missed that too I just sat there for like 20 minutes trying to figure it out on my own why is it wrong just all right so if we don't want to use the center there we go so I can hold and light up all you the Ray isn't going all the way down by progress it's making progress the power of fair programming all right it's amazing that Cube got Jason in here the other Jason we would would be doing extreme programming or mob mob programming oh I know I was gonna send him a link to but I couldn't find the punting kugel chat look give me a week I'll figure out how to get OBS working and all three of us will be in here if you want just sigh if you got them on Google Chat just send them the zoom link you can hop right in to give me a chance to run to the bathroom let me ask another drink Jason you wanna hop in the car real quick so just a shooting just sended the invite link and keep going over the stuff so that's working they're lighting up I do need to run off to the bathroom real quick though and alright I'm gonna I'm gonna I'm gonna send him a link so that we can uh duh okay go back 30 second or like two minute break real quick and I don't know if Charles on stage stands refresh I'll answer some questions Charles answer questions I'll be right back this perfect see any questions can someone oh all right so the the game we're making right now I keep forgetting what it's called shoot I think it's called a line filler let me look it up oh it's called fill fill line I'll drop a link in the in the chat there we need more Charles as well oh that's very nice thank you it can only be one Charles I think Jason's gonna hop on soon so that'll be cool I'm thinking about doing a stream I guess once a week now we're now I've been doing it with Jason this is the second week so hopefully we can do this again and hopefully I can show you that that inventory that I was working on so Charles what is your favorite green um probably I'd say forest green you know because it's all natural and I like the forest in fact I just moved in near the forest what's the idea of the game so basically there's some squares there's a game board and there are certain you know you can think of a game board made up of a grid of squares and so you click on its one and it'll light up the square and as you move the mouse around the game board it'll start filling up the the squares it's terrible explanation but I'm just gonna keep going there are some spots on the game board that you cannot fill up they're like I guess I don't know they're like blocked and so the idea is you want to fill the entire game board by moving your mouse over the squares but you can't cross over your your previous path so I don't know hopefully we'll finish it and then you'll be able to see an action have I been shadow band question regarding ECS know you haven't been shadow band I'm sorry I missed your question regarding ECS for a mid-sized our PG game do you recommend ECS or not uh I mean if performances are you're taking a real big hit on performance due to you know having a lot of concurrent operations or a lot of data moving around in your RPG maybe you've got a lot of things you're managing like a weather system and you know what dialogue system and there's like all these things that are happening all the time while your player moves throughout the world then yeah I mean I think CCS would be valuable but yeah you don't want to put the cart before the horse you don't want to leverage and get locked into something like ECS you really don't need it but I mean I've always liked DCs obviously I did a whole series on it so I mean if if it's something that you think will be pretty data intensive then yeah I think go for it you could definitely leverage GCS what else Charles please lure Jason over to the dark theme before my eyes burn out from a display yes well am i using the dark theme immunity i when I use dark theme my eyes burn out there's like I got my room super brightly lit back kinda drives me nuts how dark it is right now I've tried you know it's funny about the light theme though I've actually heard that it isn't necessarily true that the dark theme is better for your eyes I've actually heard I've actually heard that light theme is act is technically easier to read something about contrast yeah my eyes are super super sensitive like I'm deaf as hell but I can't hear anything but I can see really well and my eyes like they get overly they get overwhelmed if it's and anything bright pops up like if I use a dark theme it's fine if the text is relatively dark - but as soon as something was bright and shines like it just kills me and then I got you know all the monitors around me so like the darkness and the brightness it's it's too much I totally understand that I have a lot of friends who just love dark theme for some reason I hate it cool it was there anything else or should we just get back I don't know if you were in no we're good there was a couple questions I think I got them all okay cool well let me check actually let me check my shadow I'm sorry guys I'm neglecting my own chat yes terrible by the way we're at 99 mics anybody lucky number 200 wait hold on a second you're at a hundred I'm only at 23 come on guys let me see what I got on my side okay in case anyone's curious I think hey other Jason's on hey other Jason welcome I wanted to run my own logger that uses conditional attributes but I realized I needed to make some cymbal manager yeah I go the other chefs I'm not hearing triplicates oh boy while Reed will real-time spotlights always put the S put the FPS too impractical lower values you know I I'm not really a big expert on lighting but yeah I know with real-time yeah with real-time lighting I don't they're switching from enlightened so I don't think they've worked out real-time lighting yet with like the new HDR P I don't know if you guys have any thoughts on that less of a programming question nothing here or now I still barely use HDR P stuff yet just because I don't have any real purpose the real projects that I have that are big they were already in development and they're probably not switching so it's something only using small experiments really gosh yeah well what I can say about that is that a real-time lighting yeah I think they haven't worked it out yet hell yeah man 23 watching and I got 27 likes nice thanks guys that's a heck of a ratio 487 away from 200 now there by the end I think thanks guys you're awesome so I guess if we get back to the car by the way I have like about 45 minutes left maybe an hour then do this again of course but hey yeah our weekly out if we can muster it I'll be done yeah it'd be fun I think these are a lot of fun but I was thinking what we need to do is make it so that these reset real quick like when I release just do like a game board reset that make sense yeah and then we can go into the logic of whether or not a thing should light up so we'll need to keep track of when you press down and when you let go yeah Jason can you see my screen share and zoom by the way have you had the updated version so I think everybody else is like 10 seconds behind or something yeah windows like and simultaneously see the chats and also many tabs so many chats people ask me why I have so many monitors no I anymore God if I'm gonna start doing this more often I have to pull out one of the old monitors I switched to m1 ultra wide a while ago it seems to be the best for coding just one giant ultrawide monitor but I've got like three inboxes in various corners of my office that I can set up if I need to have a chat dedicated view yeah I find looking left to right is more difficult than looking up and down what do you guys think about that sorry to go off-topic I never look at that monitor over there I look at these two and that one just plays videos and like it has the crap that I can't look at because yeah it's too far to look like just just going left right I think I've tried every variation of monitors at some point I remember while ago there was the eyefinity line of graphics cards and they had the micro display ports so you could have up to six monitors plugged into a sink a graphics card oh yeah and I had to set up a nice six monitor display and it was just insanity it's just too many screens it's miles so I eventually end up switching to jewel monitor and that was great but I didn't like the bezel down the center switch three monitors and I found that despite three monitor what I would keep doing is I would keep dragging Windows from the sides into the center when I wanted to deal with them it was almost like I would say focus point and the rest was just arbitrary so I realized the points of the second monitor they're not to be working on it or is there to be display monitors so I ended up switching those to being vertical displays and that way you can have them as strips for chats and things like that and I would use it for Skype so I would use it for and mood boards or for things I was working on or alternatively you'd have it for your to-do list if you're doing like agile boards or something you'd use the boards on one screen but after all of that I ended up realizing that I I just prefer one giant monitor it just saves a lot of messing and yeah so I've done the whole rounds yeah I'm still I'm not sure what I want to do I'm in the process of maybe stacking my two 4k monitors and then getting one long one to put vertical for like code or discord or whatever but uh yeah I just maybe I need steam to get rid of this bezel because I think I would drag Windows right in front of me if I didn't have the bezel there I don't know I just fused three three monitors that match do you guys use stream decks oh yeah I switch my lights between white mode and different sets of colors though that's and I use it to switch my speakers from headphones to from mydaq to my normal speakers so yeah that's pretty much I want to use it for random stuff like that to things where I would want a button and need a web page or something okay I was adding the reset stuff here so if we do a reset on release should we I'm not sure what we should do because right now there are two things going on right the the Gamecube doesn't actually do anything like we call Phil actually where's this called from again I'll call the Phil but we should probably set something in the game board yeah to keep mean because the game board is the underlying data structure actually you know we should do is make in the releasing we should reset the game board like that right some sort of a reset and then I think I don't know how they implement that yet but I think then actually I do I just go through and zero em all out of thing but the other thing we need to do is call into the view and tell it to redraw the game board right or to refresh the game board so instead of or should we make the board I mean I see what you're saying I mean I feels a little expensive but yeah I mean instead of having to keep track of every little bit something okay let me go back and I'm a you know unfill these or whatever you're just saying screw it I'll just wipe it out well we can just reset him I'm doing a draw is probably bad would probably be like an update but I was then I was thinking maybe the game board view should just know that the board got a bit a position changed everything changed in there and get reset but I don't know if it necessarily needs to you can call when you do draw a game board on the like the game board viewed can just keep track of all the GameCubes like have a list of gamecubes that it creates and then when you call reset on the game board view it could just loops update them all through the cracks day it just said empty yeah so if we keep like a list of those what if we do it like that one all right all right just make a match I would just MIT personally at this point since that doesn't really matter I don't really care where they are I mean maybe it does matter but this feels like duplication of logic I might just make it a list and just loop through them but no it doesn't matter you're already doing the whole thing we already have well the index is right here we just um yeah kind of map from one to one I don't know I like to do it looking good so now so now you just populate the yeah yeah make it that with game board columns game board rows and then we just set that right yeah that gives us all of the cubes and then we can add to refresh or I really feel like we should just get a call back when something changes on the game board hmm all right well it's doing a refresh this is really like the draw so just loop through I mean I would say you've got a pretty solid boundary as it is the game board doesn't really know about you know the GameCubes or the game view so you know I still think that I would have I would have had some intermediary I find that the view is a visual representation of your data model and your data object is your kind of is the board itself it seems to me that we're now deciding what renders and the view relative to the data in the model that we're basically leaning into because this is event-driven as opposed to an update loop we've basically got our own little MVC model here now normally I think we've all run it before how you don't really want to use MVC in unity as a given because it's not really what it's built for but MVC is built around event-driven architecture and this is pretty much what we're doing we have a model which consists of a bunch of data fields and we have a view that's how we're drawing it it's structurally if we're making decisions about when things should clear or refresh there should be something like a board controller which would take interview taking it board and then draw that board to that view and that way the controller can decide what logic applies and we can swap out the view better took to the keeping the same board and controller yes yeah I like that approach too because right now we are pretty much we're going all in on the whole cube thing as opposed to you know making it something that we could swap out later with a different different representation there's a reason for that though because we're never gonna swap it out we're never gonna do it yeah yeah I can see the game board viewers are kind of are universal our game rent game board renderer I guess is the entire it encompasses the whole process yeah I think if we were if we were looking at something bigger more complex where we actually had a use case for swapping it out it'd make sense we were doing something simple oh man I love over-engineering I think so I was thinking here instead of a fill and clear we should just have this be like a toggle state so you know can I send a true or false and then we can pass in the bowl from the GameCube it's like a toggle and we just you like if it's on do the fill color otherwise the initial color you can swap this down and make this nice and tiny too well if this is the angle we're going then I think Jason was right when he was saying maybe it's a good idea for us to perform actions on the board like clear and that dispatches an event that the view can look at and then perform the clear as well so maybe we just have some board changed event and then the view would just subscribe and perform changes relative to the data change I was thinking the same thing the only issue I wasn't sure on was um yeah actually no that makes sense he's initially I was thinking there was gonna be controlling things from the view but I think that yeah what you're saying there make sense so the idea is just that um on the game board we send some sort of an update or an event whenever a thing changes right I went whenever the state of a thinking so let's see let's make the GameCube do this so GameCube problem let's see okay well we can get the position of it so let's see that will get the column in position and then set it on the game board mm-hmm that set or say toggle and we give it GameCube column comma GameCube dot row comma true is there ever a case when we set something to false on here no so just you fill because the only other time is we reset right no we can undo if we release or if we go back over things it under so let's do toggle to make a toggle method here and then we just set positions at that thing equals on and then we fire off an event so this is this the fun part like a public event action and come in come the wool position changed or I don't know what do I name it the same right to you guys I was thinking this would be column row state we just register for that I have you I usually go with the the standard event syntax of naming it's an action verb and then you'd have your internal say changed and then unchanged would be the internal like I'm Cube changed well I would have changed be the event you subscribed to and then I would have a protected unchanged function inside of this class that we call wherever we need to fire a change event because the gate the game board is the thing that changed in the end of the day so I think you're safe to just call that like yeah because you're literally saying or not changed and that's that that's the thing you're subscribing to so it's kind of baked into the name more like this but you just wrap him in a method yeah because there's I guess it's not as relevant these days but it was mostly to do with with the risk of not locking so you need to have a you need to cash or event just just prior to it okay oh I see okay so if we we make the event here we fire it off there oh and then here I guess in reset board we just do a loop through all of them it's that little loop so they don't like copying that but really what we got to do is just go to toggle and those and that should just turn them all off and fire off the event for all of them right so we've got a reset we've got a toggle and then in the game board view when we draw we're really binding so just because we're going to register an event on a rename it and then we'll go like if game board is not equal to no we need to deregister so do game board changed - equals handle game or changed and will generate the method for it and the reason for that is because right after this I wanna do a game board that changed plus equals and okay board change so we're just wanna remove the registration if we change boards so that the old board isn't still linked and then this is column row and on okay so we're almost there so we do have a game board changed so here's where you call your Gamecube does still yes cubes dot column come a row dot toggle on set it then we don't need a refresh right well you might because you have that reset in your game board you might have an event that's just gonna call this anyway though I mean we could optimize it so it doesn't fire off an event for each one but I don't think I care at this point is it's alright yeah well I mean it's gonna fire off the event when we do a reset but that's I understand you do a rule through each one a hit toggle on each one yeah okay it makes sense yeah if it was something we were doing common like often in an update or more than you know a dozen of them may be there but I think here it'll be okay are we missing anything to make this work should be able to draw now and release and see what errors you get there's got to be something missing there's errors or we never a case where I just code it all and I didn't miss some line of code somewhere at least it's rarely a case unless I'm writing tests and running the tests first ok so there we go I can draw if I release oh look at that it's beautiful it actually works one of the questions I saw there was no checking every frame is there much overhead to worry about not really doesn't really affect you that much as you start to get to more advanced stuff you might want a favor and object pattern in certain cases where you can strip out some of the null checks or if you use defensive programming as Charles mentioned earlier he tried to exit out earlier so what you can do is you still have to do the null checks but what you can do is you can structure your null checks such that it does the cheapest one first and it ignores the other so doesn't have to do it if you incorrectly structured them you can end up with a case where it does three fail checks before it moves on so there's a couple of things you can do to optimize it but fundamentally not really like you don't really have to worry about null unless it's unless you're doing like 15 mil checks in an update and for no reason and in which case you can probably find a way to wrap that in some other object and then if a single null check that equates to the same thing so it's usually not an issue even then you could have hundreds of thousands of them if they look realistically right people don't notice this but if you start if you if you do the whole f12 thing and dig down across all the different layers that are in built into unity and even in even in just standard c-sharp if you're looking at things like how strings are validated or how the any of the two string functions or all of those those sort of number formatting functions if you if you f12 down through them you'll see there's an awful lot of null checks that are going on that you don't even think about there's already layers upon layers of null checking that's just existing so yeah it's just a nature of how code works so fortunately yeah and it's not it's not slow though that's the main thing like if you're worried about it for performance don't in fact I'd say generally if you're worried about things for performance profile because usually when people guess what the problem is they're wrong they it's very very rare that people guess the right problem even people who've been debugging and doing performance optimizations for a long time like guessed wrong all the time like and if you haven't done it a lot you're almost I would say guaranteed to be guessing at the wrong things and fixing the wrong issues profiler will tell you exactly where the problem is what why and it is how much time it's taking and how to you know get a good idea of how to fix it and another way to put it as well is the cost of throwing and nul no matter how bad it is it will never be as bad as an old firing in your update consistently you know so realistically there is no it's not even worth the question of should I avoid no checks it's more a case of you put the null checks in providing it makes sense for your code and you know it's always better than the alternative because if you do any kind of because people don't realize what an exception is an exception is fall on breaking the flow of execution it's not just a wrong path it is completely breaking how the code is right is running so you really want to avoid actually throwing exceptions far more than you should care about any kind of null checks totally agree somebody asked about releasing the video it'll be up after this it they automatically go up and then we'll do an edited version later and then somebody was asking about the the array I don't know if any you guys either guys want to explain it the double array or the jagged array or the multi-dimensional they're multi dementia right so when people think about write array is just a fancy word for a list right and for sort of programming terms there's various reasons as to why it's an array as opposed to list for that's not relevant the important thing to remember is it's just synchronous data it's just ABCD one two three four that's all it is and so when people start talking about multi-dimensional arrays that's just to two dimensions and the same way we've 2d versus 3d it's just an extra dimension so another way to put it is you have a b c d or a b c d and one two three four so a two dimensional array lets you work on two axes so it lets you have things it's perfectly designed for working with grids because it's literally displaying data in two different and you can keep adding them it's actually you can have multi-dimensional arrays that are mostly infinite but your going past three you're probably in dangerous territory and shouldn't be there yet but up to three dimensional is probably about okay and the reason we do it that way is because it the core of how it works a two-dimensional array is just an array of arrays so but another way a list of Lists so it's the list of ten elements and each element is another list but the problem is if you do that you've got a number of issues for example each this can be different sizes run at it to the other list so you could have a list with its staggered and that's gonna be really difficult from doing a lot of complicated stuff to do with array indexes in most cases when you're doing 2ds arrays you're doing them for a grid so long story short a multi-dimensional array lets you define a list of lists whereby you set a size on both axes and that way you can work with it quite easily and it saves a lot of hassle so that's that's the TLDR there's a good explanation yeah usually when I see them used it's for things like 2d grids or 3d grids where we usually use most of the time cuz things where you always want the same x and y or x and y and z and I don't think I've ever seen one that went above three like you and that's other thing too is so made a good point the interesting thing about arrays too is that the way arrays work is kind of clever insofar as there's actually a really simple equation it's just a very simple math equation that converts a single array into a 2d array and it's basically just taking the iterative size of each chunk and dividing it out and you can effectively turn a single array into a 2d array in terms of just having the right index counts so it's more efficient to store memory continuously in a chunk together so a lot of the times what happens is a 2d array is actually in memory just a chunk of sequential data but there's a special way in which you ask that data how to get an index out from two indexes so it's kind of like some of the other code you would have seen which is sort of divided by the width of number of elements and get the one at this index it's not that complicated it is a little hard to explain but that visual aid but effectively it comes down to it's more efficient of memory to store a single contiguous chunk and the difference between literally making an array of arrays like we did at the very beginning we're confused about versus an actual multiplex larae is it'll store it continuously as one chunk so it's far more efficient even though it's technically from a using standpoint exactly the same thing has a great explanation somebody asked what we were building or just building this level game or this line thing we'll get back to that in just a minute too but it's basically this where you fill it in and you can ya beat the level and we've got that kind of done well we don't have the part where you can beat it done yet so we'll have to do that next and then I think there are a couple other questions to see um somebody asks about the master course is it for beginners kind of it starts off beginner friendly but it gets into more advanced stuff so if you're beginner it's an okay place to start I think I get an architecture course that's definitely not that's coming out soon but if you're looking to start it's a it's a good place for beginners if it doesn't work let me know or if it didn't work for you well let me know but I think it should be yeah and somebody asked about do tween I used to use do tween all the time when I first started using unity I don't know about you guys did you guys have used it I relied on it heavily and then I found that I stopped using it think I'm a dummy I call it ice called dot tween oh don't remember hot tween is what it used to be before do you remember I don't know what it is I don't know I don't I don't use it anymore but I used to use it a lot from things around now I can be used animations or very specific code for things what about you Jason new stage new queen oh yeah all the time it's firstly it mates makes its way into about say 3/4 of my project because a lot of work I do is sort of prototype vertical slice stuff for clients so there's a lot of sort of swishy animations and stuff that goes into that every expense we do use it with musi - right I do although I don't like what they've done with the redesign so I've stopped using doozy these days I found a different framework I use instead they've gone sort of for a what you see did you get visual editor and it just seems like a lot of overhead for what amounts to you know managing the state of a few but um but on for the tweening thing so for people who don't know tweening is just a kind of a more animated term for interpolation and so you've got linear interpolation which is sort of moving a thing from time from one position to another or time and so the idea being if you've got a number at - and a number at four at time zero point five halfway between one to the other it'll it'll you know be in the middle so effectively tweening is just one way to animate things and it literally is just a case of adding a percentage of a value to the other value until it reaches the end so it's not that complicated in fact I have a blog post on that very topic which I'll link in a second and so the reason were questioning is do we use this but you can do the same thing with animations and animation is a timeline that's the difference in animation is sort of it runs an entire sequence of things and you can stack things up at their positions in time while tweeting libraries are just third-party libraries that do the same kind of thing but is sort of designed for smaller scope they don't serve encompass the whole project I personally like to use tweeting libraries because they handle there's something you can program easier than animation animation is great if you're doing cutscene stuff or you're actually animating a character with multiple blending but if you're just saying bouncing at sliding an object in the screen tweening is easier if you're if you're comfortable programming of course it's something easier to animate it if you're happier in unity but more so than that the advantage it has is as I mentioned the chat earlier is if you use animations on UI components in unity you are forcing or afresh constantly so the entire lifecycle of that object even when it's idle the way animators work is they're constantly pinging their position in time because they're doing it across all the different items so if you've got an idle animator in an idle state or something is positioned at zero it's still animating even if you don't see it it's just animating all of the time to the position of zero if you do a tween it's event-based so it only fires the time you use it which can be more efficient it's again it's like the whole if null thing it's not that big of a deal is that going to end your project but if you've got a giant hierarchy and in your project grows you might hit a slowdown later and your question why it's happening and it could be because you've got a big animation running at the top of your hierarchy root for a depending on how you've designed it yeah so I'm story shortened again between ins rage our youth training allowed do trains my personal favorite I train is great although the syntax uses a hashmap which can be confusing for people so I usually recommend do train okay yeah I just I used it a ton at the beginning and then I stopped running into cases where it was as useful and and I'd run into random problems importing it into different projects and stuff um it's interesting to know how much more you use it though yeah yeah and in fact is even when I don't want to use external libraries cuz that happens too sometimes of a project where you're handing it off somebody else or you you don't have people have to rely on bunch of libraries you can actually find a single file twinging libraries there's a really nice one somewhere I don't know where I happen to have a credit to as well on the top of it it's someone has just basically taken a eight hundred lines of code and just squashed the common tweening functions into one file and it's just a really nice way of just basically saying easy and ease out you know use the fundamentals of bouncing a bounce out and it's all just one file you can drop into a project you don't have to have any assets so nice very handy for that yeah you ever might go drop it on the description yeah cool so I want to fix the next issue in this thing so when we left off like we can draw a level and it fills in and stuff but there's still some things that we can do we shouldn't be able to do like they can go back here and then come back down and draw and fill things in like we need to only be able to fill in the adjacent squares it's a ferry that would be like a next um fun easy thing to do alright we're just so to do that I guess my thought was in this try moved to new cube it's called try cuz like it should fail sometimes do we just do a check here to see if this game cube is valid so once we've raycast as we figure out the cube just check to see if that cube is Valley is a valid option with the game board right so to say like game board is valid or do like some validation checker that just checks to see if the point is valid yeah I mean on the game board itself that be easy cuz you just check if it's already true then you obviously you know it's it's not valid but another thing to consider is what valid also needs to take into a fact into account the previous yeah queue so that see I don't know if that's a job for the game board though I mean I think the game board does need to tell you if it's valid based on the whole true or false but it seems like the get the game controller is the one who can decide it should do it yeah I mean maybe the game board has information about how this game is played it is called a game board but I feel like the game controller should be you know in charge of saying hey look based on the I'm keeping track of the last cube you touched so based on that last cube I can tell you whether or not this next one is actually valid make sense started to do that we would just check I'm thinking that the game controller should keep track of the previous the previous cube at all times oh the previous cube or the previous position whatever the whatever the previous one that was lit up because then it would know I mean I almost feel like because I was I was actually playing in the browser and it looks like it keeps track of the whole line so maybe you need to have like a like a stack what would it use the line for the I noticed that when I'm when you go over like if you're playing the game when you start going over multiple cubes when you go back over them it unfilled you're basically saying it's got a command pattern I can see I saw that myself it sort of has an undo redo relative like you don't move one direction and go back it won't let you move until you've undone the reverse about you've done by moving back to the steps that's no no I don't know if any dips meant that that seems like an extra feature from the original requirement but we could yeah the idea being that for each move you make we store a stacked position of each of those and then as you move if it's an invalid new position we just unpop the previous stack if you're moving back onto them I mean we could yeah we don't have to go that hand we we could just keep I still think we need to keep track of the current I guess because you thinking in Harmon just keeping track of all of them no I'm gonna get more complicated right yeah the only thing I don't like about it is that I got a reference to GameCubes in here but I don't think it matters what's missing oh I get what you're saying yeah just because it's referencing the the object that we're really using for the view but like I think it's okay the other option to be I can make a struct or and into int positions or something but I just keep the cubes here I mean the game cute the game board itself could keep track of the order like the positions that were filled and in what order because he figured look the game board gets filled and we you know we call we change its state so technically internally it could keep track of the order in which its state was changed again I probably over engineering on this in the game board yeah that's like interesting but well let's not let's not over complicated I guess the easiest thing to check is hey can I refill the same one or or whatever or can I fill this next one I feel doesn't it this next one yeah yeah or do that for now sir with that I want to go to so we needed a current column wait we have these on some warehouse right and it weren't they in the wrong spot before on the game board mmm wrong column yeah we're talking about moving them to the game controller here and this could probably be private I can't think of a reason that would be exposed so when we set the cube oh wait is valid cube by the way you got like a super Chad Oh super cat question let's check that out in future videos can you show us when it might be useful to use a cert function in our code it's a great example of defensive coding yeah I rarely use asserts in actual game code because it's just gonna kill the thing it's gonna shut it down or thrown thrown except like you're gonna end execution I use them in the unit tests instead but I see you're saying I used to see that a lot in a lot C++ games where if things went really really bad on the server like it would be bad to just kill the whole process but I almost never use a certain actual game code anymore I don't do you guys ever I mean like you said I only use them in unit tests I know that the assert the Unity engine has an assertions library that I haven't really used it yeah isn't it an unreal and basically use it to kill the server if something went terribly wrong well I'm actually on the documentation here and it seems like I don't know I don't know if there's some sort of built-in functionality with unity where if you use their assertion library it'll do something special that like because I see here it says an assertion exception will be thrown in order to pause the execution and invoke the debugger so I don't know if that's a way it's a unity specific way to be like hey look I'm not gonna kill the program but if you're debugging inside of unity it'll pause it there like maybe it does something like that that I'm not really sure that I'm not a hundred percent yeah no me neither because my history came from c-sharp sort of line of business software as opposed to games the assert is used there almost exclusively inside of tests the same as Jason will say because it does it basically breaks execution but here's a little bit of story time relative to this idea if we're talking about defensive programming basically there's a bit of a war on the concept of exception handling so as people who are catching up with with the latest version of c-sharp and stuff there's a major push now to have your code work in such a way where you have to define which variables are notable long story short it's gonna make it so that you can't have things which aren't know like even your strings can't be null and everything has to have a value unless you define specifically that it can be null and the reason they're doing this is because this is the latest take on the idea of knows break code knows fundamentally are they're not even a bad object they are the active missing portion of something that's being ferried through your application they are a problem where somebody will have to handle it either you're handling it at one place or you're just passing the null down the chain until somebody handles Nullah by definition is a mistake it is a thing in your code which is not there but it should have been there and there's been a whole load of different ways to handle this the the old way from Java is to use try cache blocks it's you basically the giant try catch block and you say if this breaks catch it don't put to an exception Handler and then run a specific piece of code handle when this happens the next step up from that is the idea of people saying code defensively don't let your code ever run in an invalid state and that basically says the first guy who gets an all handles the null and cuts it off there and what you do is you decide is this null game breaking or can I recover from what if I can recover from it I run as if there was no null and I keep going if it's game breaking cancel my app and break it from there that way I can go out that way you don't end up with data in inconsistent state like you know when someone's user account missing an email or missing an account balance or something because that's fundamentally gonna break your application after that there was this whole phase in the middle which people may have forgotten and it was the sky native called code contract so designed my contract and it's where it's the same as the as we've done here if this is null or if this is false break out of the application code contracts were a way of saying this code will need this data to look like this before you even continue and it's a more formalized version but it failed to take off because it takes four or five lines of code to define what it's effectively this should be null or this cannot be known and it's it's a horrible mess of code to write that really ruins their kind of readability of your code so that brings us all the way today and how we're handling it is well let's not write no logic at all let's try to avoid it and the way you avoid it is one of two main ways you either make placeholders where null might have been and that's where the null object pattern is worth looking into it's basically make a version of the thing that you want that has zero implementation and the orders note you also known as the jacent of something similar at least I think it's you doesn't who writes your events where you assign a default delegate to your events beforehand yeah I used to do that all the time now I use the question mark dot instead yeah never invoke without it exactly the buzz out of the same reason which is you don't want to be dealing with no threat your code if you can find a way to assign even a default value to something it's better than having a null value because again nobody was broken it's not just a lack of a value and so that's where we are now we're basically dealing with how do we get rid of moles in our code and we're coming down to the fact that let's just not have knows at all that's sort of the general consensus and people are moving in direction so it's a messy topic in terms of how do you handle nulls and gold in general it's interesting though because I use knowable primitives all the time now I could especially for data that is optional they have lots of optional data and some stuffing these nullable primitives for a ton of things there in the case where it could have this thing it could not it's a hundred percent optional yeah and in their mapping to a database of course to where there no binding from models from a web api like if you're calling an api service and you're getting back to json object they're gonna need notable objects to represent those and as a small aside if anyone's familiar with JavaScript as well as c-sharp it's the name for that is actually an option there's there's another design pattern specifically more familiar in JavaScript called the option pattern and that's the same thing as the nautical object concei sure it's basically a thing it's like a container of one element and that either has an island in it or it doesn't so instead of passing in all around your code you say it's either it's an object that's either empty or it's a list with one item in it and it's much cleaner way of using your code because then nothing ever breaks it's just a empty list so it's it's a bit weird syntactically but it fundamentally is a much nicer way to handle it than letting an oil propagate through your code so I think might be all we need I was just looking at the corner because I've been watching the code all I did was add the Isabella cube thing here add a get that just wraps those positions it's just pulling back the positions and if the state is true so it's already on and we should return false the other thing we need to check is that the distance from this the current cube to that cube is just one unit right right and we could do that with just the columns of rows so well here first let's see so if we set a valid cube would toggle it and we'll set the current cube current column to column and the current row either GameCubes row and then here we can just check if let's see how do we check how do you guys one check this so at this point we just need to check that the column is one different and the row is the same or the row is the same and the column is one different that's really all we have to check right it's or like yeah so it's either the column equals our current column yeah and row changed by one then we return true right and then also if the row stays the same and the column changes by one so I would just feel like you can just do current column did take the absolute value of the current column minus column make sure that's equal to one it be the absolute value of this right and then just make sure that that equals one or over the other way right do we even need that absolute so we'll just do that I guess depends on if you know it's going up or down or left or right that's right right so this would be up and down swear unit-tests come in handy and then we change this to row row hey does that look right hey obviously not the fact the cleanest but if our column has stayed the same and our row has changed by one or negative one I guess that would be math dot absolute would have done that huh I don't want to be the one to say it it's easier when you're not writing the code yeah math dot absolute by the way just turns negative 1 into 1 so if we get negative 1 or 1 we'll get absolute just the positive version of the value I think that's it so I should tell us if the cube is valid and only let us go to new cubes so now when we do this selection would get skew check if it's valid and then only toggle it on and only set our new row if that's the case in our current column and row here's the problem right that's going to start off as 0 so that making we kept my start on block 0 0 here let me let me around and show you how I use my nullable Oh anybody wants to see how to how to do it with no vowels you like this dot value and dr. value make sure it has a value and then here you just check to see if if that has value is false or current column that has value is false return true they're all valid here's me over you might wanna put a exclamation point in front of that after the or where not current volume has value could you put up oh yeah or equal false that was false I only put the W equals false there just because I find like when I'm doing videos it's super easy for people to miss the yes they're like yeah I found people miss it all the time and then if I just do double equals Falls is very obvious when they're copying something if you didn't know it's pretty cool the way building up around work so on line 67 there what the compiler is going to do is it's going to say if this value was false and if it is false it's just gonna move on it's going to return true it will never actually check the second one the double pipe symbol will only ever check the first one until it fails the validation or succeeds it and then moves on if that was a single pipe it would ensure to validate both claims that's not very relevant in most cases but if you're just as a protip people who get confused whether this does happen this is fine because their fields their fields are you're checking but if you've got a function that returns true or false and you've got it in an if statement and you've got if this or this or this or this it'll only ever run the first one it won't actually run the others unless they are single pipes with their SS just simply keep in mind it comes up very rarely but it's very worth knowing yeah and I would say in general if your function is doing anything other than just returning back true or false it's probably shouldn't be in an if statement it tends to be because the problem is people don't expect that right like they look at the code they expect this thing that's in an F statement to not be running and executing things and by default you just assume that it's checking I've run into that many times it's pain but yeah here it's just really this should never get called like there's no situation where our code is running where this should get called but it's good to have as a check in case the code changes that a side-effect so the idea being that when you read your code what you see it should do exactly that as we were saying is if the code did something else like it was setting a value in the background they'll be a side-effect I've been unexpected outcome from running back piece of code so whenever you're naming stuff and you're having from siding with the neighborhood if it returns a value call it guess if it's checking something call it jack it may sound obvious but there's a big difference between calling guess and in the background it's setting some value to something else that is not a guest it was internally changing the state of your object so my dogs are wired represent what it's doing I said don't use a property so properties setters and properties having the logic in them that sets things and changes things try to avoid those at all costs like the public properties because most of the time like if you're not familiar with it you don't remember that one you're gonna think it's just the value that you're setting not realize that it's calling some code I mean I've seen somewhere like you set a variable and it makes a web service request that save stuff off to the database and if you don't know it and they're setting it in a loop it's one of those things where the default behavior is innocuous and you don't expect the crazy stuff oh we had another super check let's answer it real quick does it matter if we use mp3s or waves in our game I have some sound effects there waves and others that are mp3s should they all be one format or odg doesn't really matter the only one exception is waves a loop well mp3's will not there's a little blip at the end sometimes when you're trying to loop and match an mp3 so as a general rule I tend to use a way of whenever I need something that's going to loop in fact I used pretty much wave for everything although there's no real harm graphics race like it's not that the compressions and unity is efficiently good that you'll be fine for both so that's my take anywhere yeah I usually go with mp3s just for the the project size that's unless they're small short little things and they use waves too but either haven't really run into a problem with audio in the very long time unit either since like the three point necks days yeah I would say just mp3 is most of the time or waves if they're small like IO and worry about too much oh this is working by the way so I don't know if you guys saw it actually did it it did what we wanted so I can start here I can go left I can go right nothing happens all the way over here the only spot that'll work is that bottom left corner and I can draw all the way around and release love it beautiful look battery um so I only have like ten more minutes until give somebody a tour of the house so I wanted to wrap up with a winning the game real quick I figured like we could just count the number of blocks that are enabled and if it's all of them you win yeah that's the worst account and I think maybe we're going to do an edited version to show how to block off levels or maybe do another call next week and just show how to block off cubes and spots on there and stuff I think that would be a lot of fun too it's one of the things that's missing because right now we can define a board of any size and shape but we can't put obstacles in there like that would be good and really all we have to do is like turn them to true or maybe add a new state that's blocked or just not show a cube there right like that's the easiest thing just don't render a cute in fact I think that's probably the easiest thing it'll just make a mask that blocks and have it not render cubes in those spots because then we don't have to change code at all sorry I might be nice with meeting we use the grid style code and create a simple generator or you just you know have a text file with zeros and ones in a 2d array and then spit out different maps that might be a quick addition I think that would be cool even just having like a an in-game editor where you can just click around oh yeah a lot of video that can be fine yeah maybe we can do that next week that might be fine let me see we're figuring that out we could do like the editor version of it to take the take the stuff and then put together an editor where you can actually create maps and save out those levels if you guys are interested in that I want to see that next week hit the like button I think it's like 200 how do you visualize your event firing as Charles said sometimes it can be a bit of a nightmare when you've got like 50 different events firing and then as Jason added it could have events firing events and even getting the spiral loops how do you solve that kind of a problem well the answer is if all of your events need to be locked you need to have a way to have a single point of entry to capture incoming events so my personal suggestion is to have something like an event bus effectively there's a class that will manage the event dispatcher so the idea is everybody else talks to him and says fire event fire and fire event and he then says oh I'm firing rent and then he actually does the hiring event and the beauty of that is that intermediary section you have a gate for every single event so you can simple version could just simply be to log events as they come in a more advanced version would be to add multiple different lager types learn the text files or so on but it's not just logging it allows you to also say hang on a second I'm testing the user I want all damage events to not fire so you can put in a filter at that point and stop damage events and maintain the rest of the code while you're running so having some sort of Nexus point where all of your events looped through a single entry point allows you to have a lot more control over the event dispatch of your application the caveat to all of that is as we said earlier don't fill your application with events events should be there when you need events they shouldn't be used universally for every single thing that ever gets called in your code so when something is important enough to be not in a loop as well it's something that is event-driven that happens in your code not too frequently and qualifies as an event then have some certain event Buster dispatches it will be my again like my personal wave approaching the traffic it's not a bad idea have you used some of the existing ones out there for unity by the way yeah this one is it this is what does it BuChE or something else I forgot the company name Oh they've got a really nice one it's very low there might be interesting to do something on those sometime you just show how to use a couple of them it and what the benefits are cuz I think you just gave some really good examples of why you would want to use those two just being able to filter like that's super nice being able to have all that extra functionality so it's putting in a filled cube count in our game board I'll go to it real quick it's just an integer it's gonna start off at zero and then in toggle if we turn them on so we add one so if on is true we add one if on as false we add negative one they're just gonna go up and down and then it is completely filled boolean here that just returns back whether or not that count matches our cubes and rows since we don't have blockers right now that should give us the thing and then I think when we're in here let's the inner game controller we can just check to see when we fill a cube right like right here when we do the filling okay let's make this a method subtract select it all and refactor extract control shift are by the way extract and we'll pick a new method cost like fill cube and then if the cubes are full actually I don't want to add in here I'll say like if Ord the gameboard dot is completely filled you win I don't know how we win seeing manager download level load CNA sync zero I just restarted which should be really really weird because we'll fill it all up and then the game will reload would probably play a particle or something let's see get that we drag it around and bam and if I can't finish it okay reloads cool I don't know seems like it's working yeah it looks great and just imagine you have a sound generator for every time you select a new grid square does a nice little pinging sound for each one of the partners and we can do that so we could now people asking about events like we could add like a sound controller and just make a script like this is this is the nice thing about events right and the reason that they become really really fun when you figure out how to use them so we just feel like a start and do like was it a game board or order where do we set it we do it in our game controller we set the board we could just set it on our sound controller let me see game controller I it's tiny and it's still so we could um yeah we know well you could just make this a single denied I know it's a thank you auntie pattern but the game controller there's sure to be one game running right at least in the supplementation so I wouldn't be opposed in this particular instance for using it a singleton and just give him but the problem is I wanna I want to set this game board every time well let's see how should we set this I was thinking now like maybe it should like the sound things should just subscribe on the view this is where it gets complicated okay is like the sound I don't know I don't know if it should know about the game controller at all or if it should just like bind to updates happening in the view or if I could just find the game board to it and one of the things is do something but I think it feels more like this thing should be looking at the view I don't know kind of curious what you guys think I think that sounds like an idea for another another stream yeah I think if if I was the simple version I would do is I would have the sound controller meet the singleton I would have a method just called play sound and we take in an audio clip I would use that inside of the game controller and then later on when I'd go to dis back to go to and kind of tidy up the code a little bit and we factor it I would then make a game controller audio script that it would defer to instead which would then call the sound designer and with a couple of the two but for now literally just having a singleton sound controller with a single play sound function that takes an audio clip kind of allows you to have the sound system have know nothing about the game but the game know about sound and I think that's a that's an okay relationship in terms of how our class is connected currently they're good and I forget make a play one shot because you're gonna end up hitting issues of you don't or that I think make it play one shot and then pass in the audio clip inside of the play sound function okay okay so go just like that we'll make an audio clip and we'll make that oops I didn't do my serialize field my s field mm-hmm well I'll be passing him that as an argument in the play sound so the sound controller can play any sounds but the game controller chooses a sound and passes it to the sound the daughter oh I see then I gotta change my sounds on there oh yeah okay you can also take in a string or some kind of key reference to reference what kind of sound you want well I'm only gonna play one sound I'm just gonna play a beep just cuz we got like five minutes to go play anything cuz I got in about five minutes and I was somebody at my door so if we went into here and you're saying I guess we could just do it right here in film when we so less than ideal but did you like sound controller plays sound and make a feel for it I'll just cash it for now instead of making a singleton so it matches everything but that should hear hear it all that extra up all that extra junk and then we go back over one more time it should work you should have some sound and some oh wait we don't actually have a sound file though beep let's search for a beep in the asset store free beep oh it's right it don't work come on asset store window what the heck I don't know you could search yeah there's this asset store thing in there and it just finds files and you can preview the images and stuff it's really nice I had problems with it somewhat recently but it seems like backup and working is they had problems in the beta no no that's been there since 5:00 that's real Wow yeah I haven't used it until very recently though it was never worth using the best I found because the store was so damn slow then it would nowadays it's to make it a bit faster did it pop up somewhere there we go it's important everything you've got wave sweet alright so you got our beep set up the sound controller will add that beep sound effect to it and hit play let's see oh my sound controller let's add one get you every time okay now we'll play Oh have turn off mute audio can you guys hear the beeps yep perfect nice I guess that's working um just just good to get drives me nuts just put that little pitch wobble in I can't stand whenever someone is a game where they play identical sounds repeatedly over and over again [Laughter] Jason talking about putting in some pitch randomization we can do that in the sound controller so you can just do like audio source that pitch equals and you like we can just add a little bit of variation there and then come back in and it'll sound not exactly the same time it's one of those subtle things that you don't notice until you know what you're actually doing sort of the reasons Jason points it out oh that's probably too much but maybe the two legit but you get the idea all right you just give it a little variation and the amount you need to vary depends a lot on the type of sound anyway um yeah if you guys want to see the editor part of this let me know I think we'll try to shoot forward doing it early next week or maybe even later this week I don't know how x time works out just make sure you hit like and share the video though so that we know to do it that people are actually interested in seeing that stuff how to build out a level editor and then maybe some level progression and stuff and go through the whole process and then turn it also into a nicely edited by step video afterwards but hopefully you guys having fun with it I had fun I don't know if you guys want to say anything else go subscribe to Charles Channel Jason did you ever make a YouTube channel yet no no people keep telling me I should make some kind of youtube channel I haven't gotten around to it yes just feed Charles has lots of great stuff there go check out his channel infallible code everybody linked in the description if anybody does have any questions I want to talk to me about anything I kind of live in both dis courts so you can catch me I go buy a piece of roof so that's me hovering around in both of the discards well yep and if you guys have other questions just drop them in the comments below remember share and like the videos and all that stuff and okay I guess we'll see you in a couple days yeah hopefully all right thanks everybody see you guys you
Info
Channel: Jason Weimann
Views: 13,210
Rating: undefined out of 5
Keywords: game development, unity 3d, how to make games, unity game development, game engine, game development for beginners, unity3d college, game development tutorial, unity 3d tutorial, unity 2d tutorial, unity tutorial, game dev, how to make a game, game devlog, unity tutorial for beginners, unity tutorial for beginners 2019, unity tutorial 3d beginner, game developer career, unity game development tutorial, unity game dev, unity technologies, unity tutorials
Id: RWXAd_D6t1M
Channel Id: undefined
Length: 161min 40sec (9700 seconds)
Published: Mon Oct 28 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.