10 Steps I use to Design and Code Big Game Systems in Unity3D

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Already watched it (before it was cool). Very good video about a subject not talked enough.

👍︎︎ 2 👤︎︎ u/leshem-amit 📅︎︎ Apr 08 2019 🗫︎ replies

Always love your videos, probably some of the best Unity tutorials one can find

👍︎︎ 2 👤︎︎ u/sniffle6 📅︎︎ Apr 08 2019 🗫︎ replies
Captions
hey what's up Jason here today we're gonna talk about how to code big systems for a bigger game I'm gonna use MMOs as an example because they're really complex in the systems that go into them are pretty big as well and I've created a bunch of MMO systems in the past and really I struggled through the first half dozen or so of them failed quite a few times and had to get a lot of help in that learning process but over the years I think I've picked up quite a bit and it's become pretty easy and now I've got a solid step-by-step process that I follow whenever I need to add a new system to a game that's not something small and trivial and that's what I'm gonna share with you today so let's get started the first step to building a big system in a game is information gathering you really need to know what the system should be what it should look like and how it should act before you start coding it and putting it together so the first thing I like to do and recommend everybody do is grab a notebook if you don't have some of these they can go on sale right after school starts I just buy stacks of them when they're really cheap and use them throughout the year I definitely recommend you go find at least one maybe a couple of them and just have them ready while you're doing this now once you've got your notebook we'll come to the real first step which is to talk to game designers talk to whoever's designing the actual system some places that may not be a solo game designer who's just building the system on their own it could be a group of game designers or it could be a programmer or producer but usually it's some designer that's taking the lead on this system and you'll want to talk to them in depth on the phone or on a Skype call or something else you want to be screen sharing and just going back and forth understanding what they want to have what they want to see and of course writing down the notes and write detailed notes don't just you know sketch a word here there write down everything that they're saying that makes sense and is important now when you're doing this it's not just the process of writing down what they say this should be a two-way conversation you should be looking at things that they're saying that maybe could be expanded or simplified to make a better use of the games systems that already exists like for instance if they're designing a system that gives out items maybe it's a one of the recent ones I did was a crafting system he'd give out items and maybe we've got loot tables or item sets instead of setting up an item should it use that maybe it gives up stats right like if my new system needs to give stats to a player again thinking in an MMO context it may not make sense to go through the process of complicating up the stat system more and having a bunch of things interact with stats when I could just have this system maybe add a buff to a player that handles the stats that need to be done you know cuz sometimes it'll just be like this big system that does one little thing the semi interacts with another system and I don't want to over complicate those things I just want to take advantage of the other systems and see where I can maybe plug those in but you don't want to just do that willy-nilly you want to talk to the designers and make sure that it makes sense to them as well and if they're not thinking a little bit more advanced down the line and you're not gonna code this system up one way and then find out oh that was just kind of the the partial idea the real idea is it's gonna be much much bigger and it really needs to impact stats or have its own item system or whatever it is so just kind of go through and while you're talking to them look for these different opportunities ask a lot of questions definitely ask questions non-stop if anything is not extremely clear like oh I do this action what is the thing that happens every time if you don't know what that is ask and find out sometimes it'll be obvious sometimes it'll be okay that's kind of what I assumed other times it'll be something completely crazy that you never would have thought of and never would have guessed so you need to ask these questions once you've got that done though you need to talk to the programmers on the team you need to make sure that they haven't already started building a system for this you know if they have you need to find out why it was abandoned what happened there maybe what complications that they ran into sometimes you know developers start working on a system priorities change and they bounce over to something else and they may have some extra insight extra knowledge that you need to know and that'll help you build this system easier and faster so talk to them and then run by all of the ideas and the other opportunities that you came up with along the way so if you decided hey maybe we shouldn't mix in this system with this talk to them and make sure that they don't have some other idea that well why that might be a problem or a better way to do it you really want to work together I mean the whole point of having a team of programmers is to be a team and work together and help each other to make the best thing possible so make sure that you talk to them in depth don't just send them an email and a design doc or you know a rough draft of a thing just talk to him tell them what's going on what you've got in mind show them your ideas and your sketches if you got them and then move on from there this brings me to the next part of my process which is sketching out the UI now if your system doesn't have a UI this might not apply but most of the time if we're building a game system there's something that the player is gonna see and I like to sketch that out on paper in my notebook now I like to do this for a couple reasons the first is that it helps me build up my data structure ideas I get an idea of what needs to be there what the player needs to see so I know what needs to be sent and maybe what data needs to be saved but also it lets me come up with a decent design it may not be the best design but I like to sketch out a bunch of different ideas on paper with a pencil or a pen no eraser and just go wild with it so get an idea what that looks like and see a couple sketches I did really bad and then you go to like more wild stuff where I start going with circles and other just random shapes and trying to mix things in and trying different grid layouts and finally coming to something more like this where I've got a bunch of info and then just iterating from there and keep going now some of the crazy wild wacky ideas like the circle that I had might not work as a UI but that you might pull some really good cool parts from them and this is a technique that I learned from Billy Hollis at a BS live event a while back and I really really love it because it helps me like I said come up with cool ideas for designs but also just get that data structure down so I know what I need to send what the client needs to send and how that interaction is all going to work if I try to do this all in code the first time I'm gonna miss things I'm gonna add extra data I'm gonna send stuff I don't need to send or receive things I don't need to receive and I'll be missing things of course so this helps a lot just giving me the kind of high-level detail view of what I need to have there but once I have that I don't just start working on it instead I take that design those little sketches and I take a couple of them and I'll show them to the designers I'll show them to the other programmers I'll get into a call with them I'll hold them up to the screen maybe scan them show them a picture just get a rough idea of what I'm thinking how things would lay out again you don't want to go too detailed on these but I do put in some little fake data and I'll usually again put squiggly lines just for text so that I don't have to fill out too much but you want to get an idea of what its gonna look like filled out with real stuff so fill out some of the stuff put in a placeholder crap but don't worry about it being perfect it's not supposed to be the actual UI or a design doc that you're presenting to people it's supposed to be you experimenting sketching and getting a good idea of what you'd actually like to build data structures are one of the important things that I mentioned we get from these UI sketches now there are a couple different data structures that we need to know about and need to use the ones that really come from the UI sketching though are the ones for data that the client is seeing so in an MMO for an example we only want to send to the client the data that we really want them to know about we don't want to send anything that we don't want the player to know anything that should be a secret should never get sent because they'll eventually hack it find out and know the stuff that we don't want them to know so we want to find out what those structures are but we also need the data structures for saving player data if we've got an MMO again for example or pretty much any game with any type of persistence we need to save off player data in a crafting system this could be like what recipes does the player know what have they crafted before maybe you know what special skills do they have for crafting these may or may not be related to the system in fact in the example of the most recent crafting system I did I just had to save off the recipes it's pretty much it for the data structure for saving player data but one other type of data structure that we really need to know about is the content data now this could end up going into a database it could be coming from somewhere else I'll talk a bit more about that later but we need to know what that data looks like in the case of a crafting system it could be what does a recipe look like does it have a name does have an ID does it have a list of ingredients or a list of things that you get from it does it have some skills or whatever the thing is ability is related to it or you just need to know what those things are that are going to be related to your system and put those into the data structures that you're gonna use for saving in my example I had to have crafting recipes I had have items that are ingredients and items that are rewards or results pretty much it not a whole lot more to the data for crafting system at least an initial one eventually you may add more actions and other types of things to make it more complicated and then you'll have to revisit those data structures but based on my sketches I figured out what I needed for the current version put those data structures together and then continue on to the next part the next step still isn't coding it's coming up with the systems that I need and the controllers and the classes and thus trucks and the processors it's all of these high-level ideas of the code parts that I need and I like to just sketch these out as well now I don't write them in detail I want to be really clear about that I don't put out like hey this class does this it has all of these methods on it all of these things uses these interfaces I've done that before it's always wrong never guess right on paper instead what I like to do is just kind of block them out just a little square showing the key parts of the thing like hey this will have some sort of a controller on this player it'll have some system and it'll have some data classes yeah I want to get those all kind of down and just a rough idea but I don't treat these as like the end-all be-all these can change and they often do change it's just a rough idea to get me started and have a kind of an architectural idea of what I want to build now I want to go over the different meanings of these different things so a system in the context that I use it is generally a class that's there for running an entire system so in the case of crafting I may have like a general craft system but I don't because it just doesn't really make sense here because crafting is per player there's nothing really generic like per world now if I had something that was happening at the world level like a zone event or a world event type thing or a world variable that stuff would go into a system that's just a one-off and I generally want to have one of each system I guess is kind of the point there never be a situation where I put together more than one of a system and again this is just the wording of the code and the classes so this would be like a crafting system or a variable system or whatever it is now when I get to the more specific ones to a player that's where I go to these things that I call controllers so here I'd have in this example a crafting controller on each player so player gets instantiated and then it would create its own crafting controller that crafting controller would have a small amount of data not much just enough to know like perhaps what the recipe is the player has are and whether or not they're currently crafting that's pretty much the level of data that I want to have in there I don't want to store a lot it's mostly just methods that do things so what would a crafting controller look like oh it would probably have some methods on it like begin crafting cancel crafting send recipes to a client maybe learn recipe and forget recipe and I think that's probably about it you may end up with one or two other things on there but it shouldn't really grow too much beyond that to just have those specific things now if the crafting system has special actions it may be like you know process action whatever and then the crafting controller does that as well and the state may grow just a little bit there but in general it's gonna be a relatively simple system that's only responsible or I said system but I meant a simple controller that's only responsible for doing that thing on that one object now it's also important to use an interface now you might think why why do I need an interface it just adds complexity and doesn't really do anything and sometimes that's case if you just add an interface and don't use it doesn't doesn't add any value doesn't help but if you add an interface and use it properly you get the benefit of being able to unit test so you can mock these things out you can replace your crafting controller with a mock controller talk about that a bit more later but you also get a nice simple spot to see just how big and exposed this class or interface is if you have an eye crafting controller class or file it's not really a class it's an interface you'll see in there all of the the methods and you'll know exactly how big that public-facing interfaces and if it starts to look big you'll know hey I've got a problem here and I find it a little bit easier to find these in interfaces than in classes because when classes get big they tend to clutter up and it's hard to tell what those interfaces look like when you have an interface that's like this it works a lot better you bet I don't want to blab on about that too much I want to go on to the next stuff the last thing in here that I think is really important is the idea of a processor now I've recently been a big fan of these because they feel a lot more functional and what these are are classes that just take a request and some data they process that data and then they pass something back out very very simple and they're very easy to read ideally if you set it up right it'll work great now these processors could do anything like finishing the crafting process it could go through and take the items remove the items and add the new items could apply a buff it could go through and do any complicated step-by-step process that needs to do some filtering or some just actions on a set of items or set of objects or set of data that's what I use these for now these tend to be static classes they're very simple they have one or maybe two methods in them and they just do that one thing so one great example I can think of right now is I have a simple ability processor if I have an ability that needs to be processed it comes in to this ability process or a process method go step by step you can see everything that happens along the way of an ability being activated and used you can you know visually tell what's going on you can step right through it and debug the whole process and it's very easy to hook into tie into and just follow along and these work great again because they're really easy to read most stuff most code very hard to read you have to bounce all around with these nice simple static ones that just take data in and data out it's very very easy to read you can tell exactly how it works now I want to go on to number five which is setting up the databases or the data structures your game may not have a database if it's a big MMO game or a big persistent game it probably does have some database of some type it may be a relational database maybe some no sequel thing it may be some custom system that people have built but it's got some way to store and retrieve data now how you store and retrieve your persistence and content data made very so you know your NPCs versus your players levels and players abilities and stuff could be stored in totally different places and totally different schemas even like different ways you could have that content data in binary files the other stuff in a database or vice-versa or whatever you had generally I like to go with databases because they're easy to update easy to work with and easy to build tooling around which I'll talk about in a moment but you need to figure out where this data is going and how to get that data into the project now if you have a database you may not have access to go in and start adding these data structures to it you might need to contact a DBA and have them do it you know give them a rough idea of what things are and they can set it up for you but ideally you want to be able to do this yourself you want to be able to iterate fast and move quickly and you want to be able to at least understand that data store the data structures that are used there and build them yourself now if you don't have access to a database you may have a local one that you can use or you may just kind of struggle with it but ideally you want to be able to create these yourself it's not very hard to learn but it does take some time so just work with another developer on your team if you're not sure how this works and have them run you through the process a couple times just go through it with them and tell you know how to do it because you'll save yourself a ton of time and make the whole job a lot easier if you can do pretty much the whole thing yourself without having to wait on other people or interrupt people and have any possible blockers now you might also use flat files or scriptable objects or something else if that's what you're using just make sure that you understand how it works and that you're able to get data in there now if you can't get data in there I'm sorry but you really should be able to it developing without being able to add data in the development system is extremely limiting and will burn and waste a ton of your time so hopefully you can do that and now when I talk about creating this data I don't just mean creating the structures you also want to be able to fill in the data so once you've got your table of maybe your crafting recipes or whatever the thing is that you're creating this for you want to be able to fill that up with actual recipes or data that you can use the test and that your designers can use so you want to be able to create some tooling ideally now not everybody knows how to do this but if you have a background in Windows or web or anything like that you may be able to just dive right into building some tools but your team also should just have some data tooling available so that your designers can go in and put content into your game right you don't want to have a game that doesn't have content and you really want to make getting data into the game as easy as possible so if you can also once you've created these new systems create the tools for them you'll be saving yourself again a ton of time you'll save a lot of headaches and just get things out a lot quicker now the tooling systems should be built generally so that they're extremely generic and very easy to add to if your system is not like that you may want to revisit it and check and see if there's maybe some opportunity to make it very simple I like to go with systems where I can just define the data model kind of pop that right into the project and have it automatically generate something that I can start with you know maybe it's dynamically generated based on the model and then have the ability to go in there and customize and make custom things on top of that but I want to have in most of my tools a way to just drop data structures in there and have it for the most work I want to be able to get these in in 15-20 minutes and not have a big turn around where I've got this new data structure and now I need to wait a week before anybody can put data in there and I'm in there manually typing it into the database instead I really prefer and recommend that you learn the tooling process just get a little bit comfortable with it get to the point where you can put those in yourself and just make them available so once we're done with tooling once we're done with the data it's time to actually start coding we're all the way on step seven so you may notice go through a whole process here before we start coding well before we start coding game code because we have coded in here tooling Code possibly and a little bit of database stuff now this whole process not that long we're going steps one through six this could be in a matter of a day it could it could be a week could be a day it definitely shouldn't be much longer than that if it's longer than a week then you're probably distracted and going really really slow if you can get it done very quickly that's great it's all just a matter of how quickly you can talk to other people and run it by them so if you get it all done in a day and you're just didn't talk to anybody then well you've skipped a bunch of steps and you didn't really get it done in a day you just kind of cheated and passed everything and didn't do the right things so I'd say get it done but get it done quickly and then you'll be at step 7 where you're actually starting to code now when I say starting to code I don't mean we're actually putting in the functionality quite yet instead what I like to do next is stub out some of the basic classes and interfaces so I'll maybe create my crafting controller in the interface for it and that's it so just the class the interface and maybe one or two of the methods that I think are pretty likely - I'm gonna use them like begin crafting I know I'm gonna use it begin crafting I'll probably use an end crafting and I'll do something to send them data I don't know what else so just put those in there and stub it out but then I also get the model classes in I want to get those into the project as quickly as possible so that I have an idea of the data I'm working with and I can iterate on it quickly because if I need to change the data model I may need to change that database and the tooling so I want to be able to see that quickly and go back and forth and this is again why it's really how well to have access in ability to modify those tools in the database because if you need to make a minor change here maybe you forgot an integer that you needed or a data type was just a little bit wrong should have been a byte not a int or should have been in not a byte you want to be able to go in there and change it you want to be able to do it quickly and not not be blocked and waiting so I like to model these out and then hook them up to the player so I get like my crafting controller on there my player now has an eye crafting controller and I'm ready to move on to step eight step eight might scare people and that's writing unit tests now this doesn't always happen first and not every project is going to have unit tests in fact I'd say the majority of them probably won't and if unit tests really scare you and you think I know okay I got to go away this is too much I don't want to do that don't worry you can still do all of this without unit testing this is just the step that I really like because it helps a ton in the long term now again I don't do it every time I'm not perfect nobody is and you know probably if I was perfect I still wouldn't be using unit tests on everything but I do like to write them and I like to write them for the new functionality that I'm about to add right before I add it so if I want to perhaps create a send crafting recipes to the player method I can write a test around that that calls I crafting controller or crafting controller dot send recipes to player and then in my tests I can check that that test has actually called and sent the network message that needs to go to the player client and we're good if it's sent we pass if it doesn't we fail now when I write the test at first it fails because I haven't written the code I've just stubbed it out so my crafting controller has the thing that does nothing it's got that method they send to player it does absolutely nothing maybe even just throws an exception as like the default you know you generate code let's just throw a new not implemented exception it might even do that so I'll write the test test should fail and then I will make the test passed and this is test-driven development or test-driven design or even behavior driven design which is something I'd like to talk more about later but it's very very similar and very close but I like to write these tests and then just get them working step by step so I'll build each system piece by piece with the tests first so get that one little chunk done then make the next chunk to begin crafting let's write a test for begin crafting then I'll hook up the code for begin crafting I'll make sure that the test passes and I'll test it manually so this very important thing when you do a do this unit testing in unity it's important to not think that okay just because the unit tests passed everything is good there's a lot to the engine a lot to the game and you're gonna miss something your unit tests aren't gonna cover everything yeah unless you're really really good at them I would say I'm not that great I never cover everything so you want to run these tests manually and just look for other issues and when you find them add tests around them now I want to be clear that I don't generally test anything on the UI in unity I don't really run any automated or unit testing there because just find it to be tedious and kind of a pain and not easy it feels like more work than it's worth and the UI doesn't change that much so I don't really worry about that it's much more on the important functional parts of the server code or the game logic code the things that you don't want to break so that your players experience is optimal and they're not able to easily cheat or just break the game in general so this is kind of the process I go through and I do these tests I write the code and make it all work and then go on to step 10 so once I've got it somewhat functional it's working I think that it's gonna be pretty close to what they want start showing it to designers and start showing it to other programmers pretty quickly now I go to the designers first because they may have some bigger ideas for oh this actually isn't gonna work this way because I forgot about this idea or I like that but I'd like it if you could show this extra little bit of info here or whatever the thing is they're they'll have some really good ideas while you're showing them this stuff and iterating on it and make sure that you're in step 10 now and you iterate just build the first thing send it out ship it and then move on to the next thing build it call them up show it to him they eat maybe even before you commit it show it to them show them what you've got well how it's going what it looks like how the interactions work and look for those missing opportunities or mistakes or misunderstandings you might have there and then you can go in there and fix them keep going and just keep iterating and while you're doing this just remember that the first thing you show them isn't gonna be perfect it's not gonna be exactly what they want maybe it is but it probably won't be so expect to show them the stuff and get a little bit of feedback and don't be offended definitely don't don't get offended or upset that what you came up with isn't exactly what they pictured in their mind that's not something that anybody can do so you want to just work with them and try to optimize and get the thing perfect just keep iterating and keep building on it and do this quickly so like I said I like to have really fast to turnarounds on these things get the whole thing kind of up and running as quickly as possible and in the designers hands as fast as possible get them the tooling as quickly as possible so they can start building and showing you where maybe there are some bottlenecks or things that are hard to do or could maybe be simplified and then go back in and iterate again don't ever just build a system and you know release it and leave it like that you want to keep building on these things and making them better you also final tip here number 11 that's not on my list put some content in the game yourself don't build them a system where they have to do it and then never actually use the system use it yourself because if you don't there are going to be issues that you don't know about there'll be things that are a giant pain in the ass things that are way harder than they need to be that designers are struggling with every day that they'll do nice and quietly they'll never tell you they'll think hey this is the way it's done I don't want to be a pain in the ass and go complain so I'll just waste an hour a day doing it this hard way when they just don't know that as a programmer we've got a ton of power and there are a lot of things that we can do to make their jobs a ton easier so you want to make sure that you just go through that process look for those and um fix them fix them right away if something's a pain to add make it easier once you've done that watch a designer do it too because you'll find that they will find hard ways to do things so always look and see hey are they doing something a really hard way is there a way to eliminate that hard way make it simpler or just make the easy and right path more obvious because if there is you want to do that too anyway I feel like I've talked probably a ton about this but if you have questions about just building these big systems in general or you have some other tips or another system that you use I'm always interested in watching other people's workflows and learning so if you've got something like that please just drop it in a comment below share it I'd love to see it and just check it out and learn as much as possible and I'm sure everybody else watching would as well also don't forget to Like subscribe and share with your friends and of course special thanks to all the patreon supporters I really appreciate it you guys are awesome thanks again everybody you
Info
Channel: Jason Weimann
Views: 57,147
Rating: undefined out of 5
Keywords: video game (industry), game development, game dev, unity game engine, unity, unity 3d, unity tutorial, make video games, unity game development, unity game dev, unity3d, gamedev, unity game devlog, tutorial, c#, beginner, #unitytips, unity3d college, how to make games, tutorials, indie game devlog, u3d, how to make game, unity tutorial for beginners, unity tips and tricks, game dev progress, indie devlog, unity dev, indie game dev, devlog, unity gamedev, game devlog
Id: Yg4yeLgj9uc
Channel Id: undefined
Length: 30min 14sec (1814 seconds)
Published: Sun Apr 07 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.