Write a Game Engine? - WHY and HOW.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I've never quite understood why game developers write their own game engines I got changed because I got to talk to Travis Roman who has written several game engines for his company and I got to ask him some of my most pressing questions for example why should you even write one is it worth it who should do it and also if you want to write a game engine where do you even get started how long does it take what are the biggest roadblocks what can go wrong I got super fascinating answer so definitely make sure to stick around if you're interested that is Travis channel after this video because he is an amazing channel about game development as well for now let's start with the question Travis why should you ever write your own game engine all right thanks Jonas so without further ado let's get to the questions the first advantage is is that you have full awareness of how everything works under the hood because you are the one that wrote it so the second point is that you have full control over the architecture design and operation of the engine under the hood you can make all the decisions on how you want the various components to work you have complete control over how those components get developed and work together and how the engine ultimately winds up getting used another advantage is writing your own game engine can meet the specific needs of your game or project so sometimes there are specific needs that you may have that no out-of-the-box engine addresses so let's say for example you're making a game that the end user license agreement either states that you're not allowed to make or that it's going to be very expensive to make because of licensing a common example of this would be gambling style games a lot of game engines have very strict policies on gambling games they have their dunk a lot of the use of the engine to make a gambling game or instead they charge an astronomical rate to actually use the engine in that manner there may be other needs too maybe there's specific needs on how your engine pulls assets down from the web maybe there's some intelligent loading or something that you have to do in order for your game to run the way that it's required by maybe the client or something like that maybe you've got special integration points that you need to meet there's there's lots of reasons out there why you may need a specific engine for the application that you're writing the answer there is specific needs of your project or game so another also been advantage to writing your own game engine is that it is a huge educational exercise the amount that you will learn by writing your own game engine is irreplaceable by any other source when you learn about how to interact with various graphics api's such as DirectX or OpenGL or Vulcan or any metal whatever other api's that are out there you're not going to learn that stuff any other way than actually getting your hands dirty and getting in there in the code and just writing out the experience of writing a game engine and failing at writing a game engine because that's probably gonna happen and the mistakes that you will make reading game engine are invaluable as learning exercises from those failures you can learn okay well I did it this way this time and that didn't work so I'm not going to do that again I'm gonna try this other way instead those learning opportunities are unparalleled by it by any other means you're simply not going to learn anywhere near as much just by using an existing game engine versus writing your own that coupled with the next point in that you get bragging rights I mean this is this is kind of kind of a big one for many people is that when you've written your own game engine and it's something that's complete its tangible somebody can go grab a copy of it and start making games with it it's available online there's massive bragging rights to be had there and even if it's not something that has been made publicly available but perhaps you've made a game engine for the for a company that you work for being able to have that on your resume that you have architected and built a game engine is huge it's not something that you see very often certainly on resumes it's just an invaluable thing to have is that experience of doing that professionally I understand did you know I have two backpacks so for a long time my phone was pretty much no you shouldn't write your own game engine no no no no no it's a waste of time so I'm curious to hear your take on this what are actually the disadvantages of writing your own game engine from a professional perspective career in that take it away so the first disadvantage would be there's a lot of invisible work and by invisible work I mean work that has to be done under the hood that you don't necessarily see right away on the screen it's everything from initializing your graphics API so initializing OpenGL initializing DirectX to work with your operating systems your target operating systems windows system I mean implementing Vulcan for example just to get some boilerplate code I think takes around 600 lines last time I implemented it from scratch so I mean there's a lot of code that you have to write just to get things sort of up and running some boilerplate code just to get a window up on the screen and render a triangle for example so so the next disadvantage is you're focusing more on building an engine within a game and this may not be a disadvantage depending on how you look at it if if your goal is to make a game then yes it's certainly a disadvantage if your goal is to to learn how to make an engine then it's not really a disadvantage I figure it is worth mentioning that building a game engine takes your focus away from actually building a game and you're building the engine to run that game instead so that can definitely be a disadvantage here kind of on that point it takes a lot more time to make a game if making a game is your ultimate goal and you're writing your own game engine it takes a lot more time to actually do that sometimes it can actually take multiples of the amount of time that it would have taken you to write the game to write the game engine if your ultimate goal is to write a game writing a game engine is going to slow that down because you're gonna have to write all this tech to then write your game on top of that tech so it's definitely something to consider well so the next point is that you are basically your own support system your own documentation generator and so forth so what I mean by this is a lot of the big-box game engines like unity and unreal have a plethora of tutorials and online resources forums documentation both for code and engine features and editor features and things like that all of these things which are specific to the engine that you're not going to have per your engine to sort of back you up so everything's got to be kept up here and if this is an engine that you're considering releasing to the public these are all things that you're gonna have to document it's not necessarily something that you see on the screen as as progress with your with your game engine or the work that you're doing but it's all work that has to be done them unless if you're trying to create a game it's gonna slow you down that much alright so the next big piece of this and this is something that I feel often gets overlooked is you have to develop your own tool chain from scratch so any editors that you need visual editors like level editors graphic user interface editors asset importers or converters anything that you need to sort of help you along with developing your game all the tools that you're going to need to support that process in fact the build process for your game engine is another thing because you're gonna have your engine and then you're gonna have your game and those two things are very separate and on and most of the time your your engine will actually be referenced by your game and so you need to set up a process that connects those two things together and makes that happen and and depending on the architecture you're set up that can get very complicated over time so it's definitely something to be aware of the final point that I'm gonna list here as a disadvantage and by no means it's just an exhaustive list of each is the opportunity for failure when you're developing your own engine the most common thing that happens out there some design decision that you made way back winds up coming and completely screwing you over and it's something that sometimes you can recover from sometimes it takes a lot of refactoring to actually recover from that and sometimes it's a fatal flaw in the actual design of your engine and it's not something you can overcome and you've got to throw the whole thing away and start over or it would take longer for you to fix that thing that it would need to just start a new engine the the opportunity for failure is very very high that's why there's not a lot of game engines out there not a lot of successful game engines anyway and that's because game engines are super complicated things and they have a lot of moving parts and there's a lot of things that are changing along with technology that's constantly changing and those are all things that you have to worry about when you're developing your own engine where if you're using a out of the box engine all those things are taking care of under the hood abstract the way for you it's definitely something to be aware of and sort of on that point is also hardware support which can also trip you up a lot of times it's sort of an additional bonus point there but yeah those are those are really the disadvantages to writing your own game example how long would it even take me to write a game engine I mean how much drug is that so the answer to this is variable it highly depends on what you want your engine to do is it to do me or is it 3d only or is it 2d and 3d does it have networking does it require multiplayer or is it just single-player type games only that in and of itself is a massive difference between the two networking layers can sometimes take months or years to even perfect especially if you're you're trying to build an engine that is capable of supporting many many players at the same time all running around in the world together and interacting with one another the networking layer can be one of the most complicated things that you can actually run run into also is there a physics engine there's a physics engine are you gonna use it out of the box one or are you gonna write your own either way you're gonna either have to tie in that existing library or you're gonna have to figure out how to write your own these days I don't think many people write their own physics engines anymore there's not really need there's there's plenty of ones that work very well out of the box there's there's bullet there's there's in videos physics just to name a couple and there's there's a lot of these libraries floating around out there that are really good that there's not really need to write your own anymore but if you do decide to write your own you're gonna have to deal with with all the bugs that are going to come up with that and all of the implementation details and that can take a really long time just like the networking it can take months or years to perfect your your physics system one final point that I want to bring up here is implementing your own animation system is one of the most complicated things and making your own game engine and can greatly increase the amount of time that that it takes to make your engine now if you have a super basic to the engine that only supports animation through animated sprites that's pretty straight forward it's not going to affect your your overall time very much but if you're writing a 3d engine that supports skinned 3d meshes and animations and you know then you've got to worry about bones you've got about worried about weights and transforms and all that and that gets super complicated really quickly and it's very error-prone and it's it's one of the hardest things that I've run into when making engines and it can increase the amount of time that it takes to make the engine greatly so as you can see by some of the information that I'm providing here is there's no one answer on how long it takes to make a game engine it really depends on what features you want in your game engine and it depends on how far you're willing to go with those features and how many features you're willing to add and where where the cutoff point is and it greatly depends on the complexity of the features that you want to add so yeah there's not really one answer to that question unfortunately so now we've already heard so many things that are different about writing your own game engine physics multiplayer variety your own documentation writing your own import role sells all of that sounds super annoying and super difficult so my question to you Travis what is actually the most difficult part about writing your own game engine what are the biggest roadblocks really curious to hear your professional opinion honestly there is one answer to this and it's motivation motivation to stay in it to the end game engines are one of the hardest things to develop especially if you're doing it on your own there are so many different pieces that go to a game engine that it's really complex to tie all these different systems together and make them work of easily people can get overwhelmed by the amount of work that has to be done it takes a lot of dedication and a lot of time to get all those things done it is one of the hardest things that you can program out there is game engine I'm not necessarily saying that that you should that nobody should try to develop a game engine but it does need to be recognized that the hardest part of writing a game engine is staying motivated to actually finish it yeah finishing is always the hardest part so one more reason why I'm writing game engines is not for me so my next question who should write their own game engine I'm actually gonna modify this question who should write it and who should not there are two types of people that should write their own game engine the first type is the type that wants to go into game engine development as a career it's for those out there who want to make game engines for a living they're not really interested in making the end product of the game as much they're interested in actually building the tech that makes the games it would be like working at Epic to work on the Unreal Engine for example the second type would be somebody who's in it for the educational experience and that tends to fall under the category of hobbyists more a lot of hobbyists like to write their own game engines I think that that is fantastic and I think that if you have the willingness to stick with it until the end it's absolutely something that you should do it is a fantastic learning experience on the flip side of that who should not write their own game and that's typically people who want to focus on the game development side of it the actual making of the game game designers people who like the creative aspect of it or who like the you know prefer the level design or the character design or the story or the sound or the music or or any of these other aspects of game development people who just want to make games and publish them shouldn't focus on engine development as much if you're looking to pump out games game engine development probably isn't for you and that's okay there's nothing wrong with that if you are not a programmer with a lot of experience game engines is probably not where you should start with that I think I'll just leave that point there but I just kind of wanted to bring that up as a as an additional bonus answer to that question let's assume you want to write your own game engine where do you start one of the first steps you need to take the first part of the same answer is relatively simple look at existing game engines look at engines that are out on the market get an understanding of how those engines work on the top end understand how to use the tool sets how to use the editors how they work differently from one another realize what you like what you don't like what works for you and what doesn't work for you and then move on to the design phase it becomes more practical at that point it becomes sort of a step and and this is by no means the complete process but I'm going to give a brief overview of the sort of process that is generally followed when developing game engines so the first step is of course bootstrapping and what that means is you get your basic systems in place like your your ability to open a window in the operating system logging logging is super important for troubleshooting especially in real time games also file system access reading and writing files it seems like a basic thing but it's something that you want to get in your engine and get abstracted as soon as possible so that you can call your own methods to open files all right so the next portion of this is is a bit variable if you're working on an engine that's going to support multiplayer the very next thing you need to do is your networking layer you need to do it early because if you leave it till later chances are you're not going to design something correctly in your system that in mind so the very next thing you need to do is set up your your client and your server and get the communication between those two working even if it's just sending text packets back and forth through tcp or UDP whichever you choose usually it's combination of both get that set up as soon as possible if you're supporting multiplayer if you're not supporting multiplayer then you can completely skip that step so the next layer is generally the graphics API so this is where a lot of tutorials tend to start off and I think this is a mistake I think that there should be some groundwork laid before this but this is the interacting or I should say the initialization and then the interaction with your OpenGL or your DirectX or your Vulcan or metal or whatever it is that you're using this is where you start to see things happen on the screen it might be basic things that might be rendering a triangle or whatever but this is sort of the next place that you start is is getting your graphics API all all set up and get that abstracted away as soon as possible the next thing is a basic asset pipeline so you wanted to find and design your pipeline determine how your assets are going to be imported just on a high level and sort of design some of those interfaces for that the next thing is how you're going to handle game screens UI interaction that generally is the next step after that is the world and scene graph and the reason that that comes after is actually because it's more important to be able to interact with your engine and be able to click things or type something and be able to provide input into your engine so that you can actually test what you're doing in the world so that way when you create your your world and your scene graph in your camera you don't have to worry about then going back at an implementing input you can just tie in your camera to input and you're good to go the next part of this is if you're doing multiplayer you need to implement object state for a client and server so in other words if an object moves from point A to point B and you need all clients to be able to see that that communication how that happens in your networking layer needs to find and set up now before you get anything too fancy done because the longer you wait the harder that's going to be in the future next if your engine uses physics this would be the time to actually set that up before you get too many crazy features in and the next step after that is obviously if you have multiplayer support you would then need to figure out how to treat those physics over the network so generally speaking you might send positional and rotational data over the network and then and then when your client receives that that type of data your physics engine would would start processing from that point and do something with it and send an update back and so you have to figure out how to make those two things interact with one another without stepping on each other's toes as far as what updates happen when how often something should update from the network and how often the physics system should actually be updating something that can be a very tricky thing to figure out and the earlier you figure it out the better so finally is tools so this is like your your level editor your asset importers maybe with a with a graphical interface you don't have to do everything command-line it's just basically any tools that you need in order to be able to make content for your engine ok that sounds pretty awesome and straightforward but I think there are probably a lot of complications maybe you actually try to do this so where can you learn how to write your own game engine the answer to this is a collection of places first off game dev net is a huge resource it's it's a resource that I've hit too many times to count over the years and honestly the people they're super helpful as long as you do your homework before asking question you know if you go in there and just expect them to guide you through every single step of the process you're probably not going to get all that much help there because they're there to help you not do it for you you know over the years I have had a lot of good experience with that as a resource also there's Stack Overflow which is super useful another one I found is learn OpenGL comm and of course YouTube videos YouTube videos are probably the biggest resource on learning and Benny box has a bunch of stuff out there on writing OpenGL game engines Trevis next question which tools and which programming language would you recommend for writing your own image first off the answer to this completely depends on platform and your target audience if you're going multi-platform one of the easiest ways at least for 2d engines or simple type games as long as it's nothing too complicated I like the html5 JavaScript type scripts WebGL tech stack because you can wrap it in Apache Cordova or you can use electron or you can use a cocoon which is another system which is freaking awesome you can basically wrap that page in an application and have an app that runs on mobile devices as well as desktop or PC or Mac and it's very flexible and because it's WebGL it works basically the same way across all whole bunch of devices I found it to be very powerful and an excellent as long as you're not making a game that is super graphic intensive if it's graphically intensive or requires a lot of physics and things like that that's probably not going to be the way you're going to want to go but then again you're probably also going to have a more specific target platform if you're if you're doing something like that so with that in mind if you're doing if you're targeting PC or Mac desktops only C++ and OpenGL all the way because OpenGL is cross-platform there's tons of documentation on it there's tons of documentation on C++ it's the industry standard for writing game engines on those platforms so it's definitely the way you should go as far as that's concerned if you're doing Windows PC and Xbox only C++ and DirectX use a literal way to go as far as those two are concerned because DirectX of course is Windows an Xbox only and it's a it's an awesome API I wish it was cross-platform because it really is a nice API to work with but unfortunately it's windows open so if Windows is all you care about and you don't care about any other platform then definitely go the right decks as far as the tool chain I use Visual Studio for all of those things because I prefer it it's a nice environment to work in the intellisense is great in it and the build process and tool chain is very nice to work with so the debugging tools are also very powerful in it so I I tend to lean more towards official studio no matter what platform I'm targeting unless I'm doing my development development directly in a linux box then I might use code blocks or something like that but usually visual studios might go too so that pretty much wraps it up for the questions I will turn this back over to Jonas thanks Travis for answering all of those questions definitely check out Trevor's channel he makes awesome videos I recommend you check out this one if you want don't want to see that for some reason then click on his channel here and find something you want to watch yeah I hope you hands you in the next one bye [Music]
Info
Channel: Jonas Tyroller
Views: 383,477
Rating: undefined out of 5
Keywords: write a game engine, write your own game engine, make a game engine, code a game engine, should you write your own game engine, how to write a game engine, learn to write a game engine, writing a game engine, make your own game engine, advantages of writing your own game engine, disadvantages of writing your own game engine, game development, game dev, game engine, game developer, how to, tutorial, how hard is it to make a game engine, use your own engine for making games
Id: Gf5mMWHWNYc
Channel Id: undefined
Length: 24min 40sec (1480 seconds)
Published: Sun Jul 08 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.