Getting Started with 3D - GameMaker Studio 2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
over the years a number of people have mentioned to me that there aren't any good 3d tutorials for J major studio - and even if you don't count the one that I made back in 2016 back when did they make your studio to beta first came out that actually surprises me a little why that might be whatever the reason I figured I might as well just jump on the opportunity to go and um make a better version of the first video that I made I put that thing out like three days after the GMs 2 beta first came out and it was at least partially kind of an apology for the the 3d is dead video that I made as a joke and people took more seriously than I expected that's just a little bit of fun backstory on that video so if you've never worked with 3d in game maker before there are a few things I want to get squared away one is that this is one of the most advanced things that you can do with game maker studio there are no two ways about that if you aren't comfortable programming with game maker ordinarily or at the very least using other programming languages and game engines I highly highly highly recommend you get comfortable with the inner workings of game maker before that the first video isn't so bad in this video I'm going to be doing what you see on the screen right here I'm just going to be setting up the I'm just going to be setting up the 3d projection but once you start trying to do anything remotely advanced the difficulty curve ramps up very fast and it will do you well to understand things like how the graphic pipes line work and what a matrix is and what a vector is if and when those kind of vocabulary words come up I'll do my best to explain them but it will be very helpful if those are things that you've already got got a grasp of secondly if you have actually watched the first video that I made on 3d in game maker studio 2 everything in that video is still valid it's just that there are easier ways to do a number of the things in there at the time when this first came out pretty much everyone thought that you had to make heavy use of the camera system and fortunately it turns out that that is not the case because that cuts down on a lot of the work that you have to do so I have here a game maker project with the default room the same old grasp right that I've been using since basically the beginning of my game maker tutorials back in 2014 23 tene I'm sorry I have a tile set to go with that's grass tile I have a room which has game maker why do you insist on opening up this side panel of the room editor all the way every time I every time I first open you the room has a tile layer why is it tiles underscore one the room has a tile layer the tile layer is filled with the grass tiles there's no shenanigans going on here with anything at all I swear there is an instance layer with nothing on it because I haven't created any objects yet if you go down to the viewports and cameras section down at the bottom and it baffles me to this day why this is why the why this section is totes so tiny compared to all the other stuff in the game maker IDE but I have everything turned off I am not using viewports or cameras or anything right now you can if you want to if you want to do split-screen or anything of that nature you would want to use viewports and cameras I am NOT going to be doing anything with split screen at least not right now so that's going to stay out of sight and out of mind firstly I'm going to create an object I'm going to call it camera I have pretty much always named my game maker objects with a capital letter and Pascal case that's because I come from a programming background of languages like Java and c-sharp which which typically do that for objects if you're coming from GameMaker land obj underscore camera is fine I just think that looks extremely weird every time I see it so if I can spell I have no idea were you talking about game or game maker but I think if I can spell that right it's just going to be camera or the capital C setting things up I'm going to add a draw event and I'm going to maximize this code window because it's the only code window I'm going to be using in this site in this entire video so there are three lines of codes that you'll need four lines of code that you'll need the first one camera is camera get active so the camera system will be in use you just don't need to do anything complicated with it cameras are essentially a new type of data structure they contain information on what you see on the screen this line of code here camera get actor that does exactly what you think it does it just fetches the index of the camera that's currently rendering stuff to the screen hey there are a few other ways you can do that you can save you you you can save you get camera you can use that function you can say camera create in the create event somewhere and use that camera for the purposes of this video camera to active is fine if you want a little more control over how you're using cameras you might want to use one of the other functions second line of code camera set view map or view matrix if you like to pronounce your words fully so this is a function that's going to take two objects two objects to their to have parameters one is the camera that we obtained in this line up here the second is the V matrix so cameras have two main parts cameras have the view matrix and the projection matrix you can think of the camera in a game as the little locket tube from Super Mario 64 who floats around behind Mario's head holding a literal camcorder and to use that metaphor the view matrix would be where the camera is in physical space and the projection matrix would be some information about like the cameras size and lens and field of view and that sort of thing let's deal with the view matrix first so to create one of these my typing skills are getting gradually worse and worse the longer I use computers but you can say matrix build look at and you can see at the bottom that it takes nine arguments if you've ever used 3d in game maker studio one or earlier versions that should look familiar the first couple variables the first three arguments that it takes is going to be X from Y from and Z from that is the position of the camera in space this is going to be where lock each each position in the world is when I'm first setting up a 3d projection in game maker or an else I was messing with libgdx a while ago and I did basically the same thing I like to have the camera pointing from one corner of the map to the other looking slightly down and I find that that is a good way to make sure that um the 3d is working and that it's doing more or less what I expect it to so I'm going to start lucky T is going to be standing in the upper left corner and it's going to be floating some distance above the ground let's say 100 the next three arguments x-two y-two and z-two this is where the camera is looking this would be super Mario's position in the world or at least the back of his head because I believe that's where the camera the camera and in those games tries to to focus itself so this as I said is going to be the opposite corner of the room room width room height that's going to be the bottom right corner and zero so it's going to be pointing down at the ground from a little bit above the ground the next three arguments exit up fly up and Z up these are not super important this is called the up Vector of the camera I'll try and put a little diagram on the screen of what an up Vector is in almost all cases in game maker it's going to be zero zero one or in some rare cases zero negative one zero if you imagined holding a camcorder and sticking a rod out of the top of it the rod would be the up Vector of the camera this depends on your coordinate system I usually use the positive z-axis as the up direction so I will be using 0 0 positive 1 is my up vector some game engines like unity and I believe unreal and also the blender 3d modeling program some other tools like to use the positive y-axis of the up vector in which case it would be 0 positive 1 0 if you're not sure what to do with this just leave it at 0 0 positive 1 and you can mess with it later if you want to pretty much the only reason you would change this is if you wanted to have the camera roll or something which I'm not especially interested in doing right now that's a telephone okay legitimate question what year was that the last time I got through an entire game maker tutorial without having the telephone ring on me okay where was I the third line of code camera set Prague Matt this is the projection matrix again two arguments if you wanted to use the lock et metaphor this is the physical specs of the camera it's holding I have to imagine that this isn't the metaphor that Nintendo was going for when they decided to use locky - and as the camera in that game I believe that was just so that they could introduce players so the concept of moving the camera around in 3d space because that was a new thing back in the 90s Hey but all the same it's really good when it comes to explaining these things these concepts so it's a korea projection matrix you have a few options matrix build projection ortho that's not what we're dealing with right now orthographic projections are to make a long story short the usual 2d projection that you would see in a game maker game you have matrix build projection perspective which is fine you also have matrix build projection perspective field of view which is what I'm going to be using right now again if you look at the arguments down at the bottom of the code window and the code helps section this should look very familiar to those of you who use game maker studio one 3d game maker studio one basically took these two functions and combine them into one game maker studio two has separated them into the viewing projection matrix which means you have to do slightly more typing but they're a little bit more flexible in what they can do and also just removes the step of abstraction whether or not you like that as a matter of your opinion so the arguments are going to be the field of view in the Y direction I'm going to go with uh I think in my original tutorial I had it 45 but honestly a field of view closer to 60 I think makes more people comfortable an aspect ratio which is oh four to three sixteen by nine aspect ratios you are probably familiar with those from video and TV screens and stuff you can literally say for over three or if you want to have more accurate to the size of the game window you can say Windsor get width over window gets height Z near I'm going to leave at one for now and Z far I'm going to leave about 32 these are the clipping planes anything closer to the camera then Z near will not be drawn if you make Z near zero then unexpected things might happen one is usually fine anything farther away from the camera than Z far will also not be drawn you can make this as big as you want if you want to enable stuff really far away from the camera to be drawing you can just add on a couple of zeros there's not really a point to doing that 32000 give or take should be fine if you set Z far to be shorter than Z near I've never experimented to find out what happens but I can't imagine it's anything very useful I made a video on matrices and use for 3d transformations a little while ago if you are curious about those I'll have links around the camera related matrices are slightly different that's a story for another video for now all you really need to know is that you can compose them by using the various matrix functions like matrix build projection perspective and so on and so forth and the last line of code I promise you four lines of code and I really only gave you T because the first and last one are really set up camera apply that's just going to take the matrices that you fed into the camera as a as their render settings and making it take effect the next time anything is drawn so I'm going to go back to the room and do I have a camera add it to the room I do not let's just drag the camera into the room that's beneath the tile layer I don't believe that's going to matter we are for the most part taking control over things like depths ourselves that's upside down all right you know what depth in game maker is weird that is a law of the universe you can probably find it in the Bible somewhere if you're using things like layers for tiles and objects when you're using 3d in game maker this becomes important it's one of several reasons why I prefer not to deal with layers and tiles and objects in 3d in game maker and use my own systems instead of fighting with it I'm going to go back on what I said five minutes ago and make the up Vector zero zero negative one and essentially flip the camera upside down instead of instead of fighting with game maker over what the up vector is so now you see we have the camera and it's floating somewhat above the ground slightly above the ground not too far above the ground if you wanted to make it float farther above the ground you could increase this value the Z from value and that will make it higher above the ground and it's going to look down across the room that's a little better in terms of seeing what's going on it's going to look down across the room at the opposite corner you may know just this is mirrored it looks like we're in the bottom-left of the room is looking across to the top right instead of the other way around top left to bottom right like I had said at the beginning again I'm not a huge fan of trying to use game maker 3d with the room editor because it has a habit of liking to invert the camera on you in this manner if you don't mind working like this you can use the room editor like this the layered depth is essentially the Z value in that case as I said a minute ago I believe I said this a minute ago I'm usually a fan of not forcing game maker to play nicely with my 3d cameras and just doing things myself I'll be talking about a lot of us in the future people have asked me to explain some of the some of the things that I've been working on and there's like eight future video topics in there that's it for this video I finished what I said I would get done at the beginning there is a 3d projection and it's looking diagonally across the room there are quite a number of things you might also want to set up that are usually done right in the beginning that I have chosen out to talk about here we have the Z buffer if you try to draw in the 3d world besides just a flat plain of tiles and you don't have the z-buffer turned on you are going to have an interest in time but I want to dedicate an entire video to that we have back face culling GPU set cull mode by default it's turned off computers like to only draw the outward facing side of polygons as an optimization so they're not doing extra work for something that the the player won't even be able to see you have control over how that works with GPU set Co mode you can turn that on or off I'll be discussing that in the future although that itself isn't the most the most advanced topic ever there are other GPU functions I've already made videos on lighting in fog and those videos are fairly straightforward there are a whole host of shader related functions I really want to talk about shaders at some point I've done very little of that on my youtube channel or they're very exciting although there are a few things I should probably talk about first between then and now if you do anything with 3d you're probably going to be working with shaders a fair amount and then of course there are the vertex buffers and vertex formats and I'm going to be this is going to get priority I made a video on these a long time ago when I did my initial game maker studio to 3d videos I want to give them more attention because back then I didn't really spend all that much time explaining exactly what things like a vertex format is and there another one that you can do some extremely interesting things with if you wanted to that's it this is basic 3d setup in game maker studio 2 I hope that was easier to follow than the first video that I made it's four lines of code the training wheel is going to come off soon if you want this project same thing as the last couple videos that I've made I'm going to have a link to the github repository which I haven't exactly been committing to frequently in this in the description of this video it's kids let's commit to master if you're feeling generous and you found that helpful I have not gone on set up a patreon but I do have in their nation link down below my name is Dragonite and i will see you all later [Music]
Info
Channel: DragoniteSpam
Views: 38,090
Rating: undefined out of 5
Keywords: game maker studio 2 3D, game maker studio 2 using 3D, game maker studio getting started with 3D, game maker studio 2 camera, game maker studio 2 view matrix, game maker studio 2 projection matrix
Id: ojfN--tdSNM
Channel Id: undefined
Length: 17min 38sec (1058 seconds)
Published: Tue Mar 10 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.