Make your first 3D game from scratch in Godot Engine!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

There aren't a ton of 3d tutorials out there yet, especially quicker ones. Thanks!

👍︎︎ 1 👤︎︎ u/ron0studios 📅︎︎ Jul 06 2020 🗫︎ replies
Captions
today we're going to be creating a marble game in which you will have to wall to your exit so as always starting with an empty plate and one texture which is the texture that we're gonna use for the ball but let's start with that once we create the 3d scene we can start adding all the notes that we want for the level I'm going to be using the notes which are here in visual instance geometry instance c SG shape and primitives these are all the shapes that you can use in your project to make 3ds things as a mock-up for your levels it's not meant to be used for the final thing but for making small game some stuff should be enough the nice thing about this is that you can combine them and you can use them to create other complicated shapes just in case that you need some extra flexibility without opening an external 3d program or anything like that so let's go with a box box is what we're gonna use for the tables where the apollo sits and everything so let's create one as you can see here you have just the block nothing really complicated and on these points that you see here one at the top one on the left one on the right you can drag and drop it and you modified how the shape looks so if you do it like this it goes wider and thinner and longer so you can start using these elements to create your level one cool thing about the other is that you can move freely by pressing the right click on the 3d scene and using the WASD keys so it's like an FPS game where you can move and the camera moves with you and if you feel like this is very slow you can also use the scroll wheel and your movement is gonna be so much faster in this video so this is really useful whenever you're like previewing or even doing some level editor stack you can navigate freely around your scene now that we have this plane let's create our character in this case the marble that it will fall down until it reaches the objective so since we want a marble to have some physics and everything we're gonna use another kind of node which is here in spatial collision object physics object rigidbody this will be our marble and when you create it it's empty there is nothing in it because the information of what collides and everything you have to add it afterwards let's hide this box for a minute and as we had it on previous episodes if you've been following or doing any to the tutorials like 3d Ingrid works really similar to that so in the same way that whenever you are a kinematic body you need to add a collision shape and a sprite here you have to design how to add a collision shape and a sprite in this case since they're not sprites although you can use one you do a 3d model so in this point that we have here let's let's add a child node which will be the collision in this case collision shape we create it and on this shape we should witch's shape new sphere shape this will give us a sphere which will be the collision of this object you can make it bigger or smaller at the same way as the other node like so when we want to the default size were not modifying anything right now and now we want a representation because if we play the game like nothing is really there so we need to add a sphere go into the same nodes we can search them easier by typing here see as the sphere I don't have a sphere here it's very blocky it's not really appealing but you can modify its properties here so if we want to add more radial segments and more rings the ball will get smoother and smoother you can go nuts with this one to make it really smooth or not another alternative if you don't want to use these kind of boxes is I couldn't remove this one and instead of doing the C CSG box let's add a mesh so here we can search for mesh and here in mesh instance we do almost the same as with the collision shape we select here fear I will get our sphere here it's much smoother I think it's parity falls so stick with this one for now let's make sure that we don't modify anything let's present this button and we close it so we have our player here now let's display again table that we had before and move the ball on top so that when we play the game the ball will fall on that there's one thing we have to do I want it to fail first so you see why now let's add the camera camera this is how the player will see your scene when are you press play and you can move it like any other object here using those arrows or the circles around any of those 3d objects makes makes it rotate so you can rotate the camera you see that Square is where you are looking at and if you're confused about what the camera is actually looking at you can use here on the a little pressing on preview and you can see what the camera will see this button will show up whenever you have that node selected so if I don't have that now selected you don't see it but to make sure that you can select it press preview and you see it so let's move this into a place there and let's preview this looks ok let's play play now and let's see what happens with our game of course we save it name and play so the ball falls and that was the order was talking about because although we added collisions to this rigid body we didn't add any collision to the box and since you are going to be creating complicated things with this one there is an alternative way instead of her in a collision shape you can here press use collision and this inspector option and it will collide with everything they have on this layer in this case both are on the same layer if you see here layer 1 ok so you should collide no problem ok we see the wall it folds there let's create some elements to make it look a little bit closer to what the game will be just to try things out and with the visual aspect later so let's move the camera I will be behind okay these first I'm gonna make it a little bit steeper so the Volvo never starts it goes and I'm gonna make it longer so we can move it much more than okay every minute here now when I read these it goes there I'm gonna duplicate this one control key and I'm gonna create another one and let's make it so that this one is let's see on the opposite side like so so the ball will fall over it there you will do like this and so let's try it out you see the ball falling which is the other side go so leave it up and then you fall down okay so let's now create the level let's make it so that you first start falling on this one then you have this one to bounce and okay I'm gonna select everything here I can do it like so I should select everything I can move it on top so I'm not under the grief okay and I'm gonna duplicate this one and move it to the other side so we can reach the end okay can I like this so the ball will go here all the way there and you have to move there and at the end we're gonna have this ashtray kind of thing where you can finally leave your marble there and that means that you win maybe let's make this a little bit smoother okay so it's not that truth if you know what I mean okay so let's start creating complicated shapes with these boxes I'm gonna create one which is going to be the same a box we'll have it at 0 let's go there and make it a bit bigger and now since I want to add a hole on it I'm gonna create inside of this one a sphere c SG sphere this fear now it's inside of the other one like they are basically the same kind of material and everything like it looks like it emerges but here on the node options there are different operations union which make them together intersect and subtract subtract we'll do a hole in this other shape so for instance now we see that the pole is carving a hole inside of that other structure so in this case we wanted to be a little bit maybe bigger yeah move it up a little bit on top and make the box a little bit taller let's put this here so it's not ok and then clicking outside okay so here we have hole on this square this one little bit on top so we will see the grid okay and here we have it this structure for now it's gonna be where the ball is gonna fall you can use these kind of combinations to do anything and if you want the opposite right now where is in the operation subtraction but if you want the opposite you can use intersection so it will only draw whatever is intersecting between those two if you work with vector graphics this will be very intuitive for you and if not just try it out combine some shapes add subtract and you will understand it pretty quickly okay so you have here our goal our end goal and let's place it where we want it which is there at the end select it and move it there see okay like we'll have it there it's gonna be kinda easy to get but it's okay for a test level we have not the basics of our level and let's start adding some of the interactions because if I press play you're gonna notice that the camera is not moving you cannot do anything with the balls it will just fall and nothing will happen so let's start setting up the camera in a proper angle that we want if you want to preview the camera and move it at the same time if you press Q and B you can split the viewport into another we have to I can use this one for previewing the camera and it's done for editing the game so in this case let's move this a bit top and this is the angle that I want maybe a little bit further like it's something like this seems okay and we can remove this view now okay I'm gonna go ahead and I create a script for our camera which will cause camera at GD we will want to update the position of the camera to be following the pole so let's first get the distance from the camera to the ball and then update that same distance of that so we're gonna t offset and we also want to have a reference to our ball so on ready for ball with capital letters is gonna be at parent and get node rigidbody so this line of code here is gonna be accessing and saving this reference so we can use later on ready let's set the offset for the first time so the offset is going to be the translation translation is when you click on any of these objects here in transform the translation is the position so if you move it you see that those number numbers are gonna move so that's what we want to get that's the same as position in 2d so we want to get this which is a vector three and let's subtract the ball translation okay so now we know the the offset that we have to respect on every step now on find physics process translation is equal to well translation plus offset so in this way every step is gonna check the position is gonna set the offset that we calculated at the beginning like the distance that there is between those two and it's gonna improve the camera at the same time let's try it out and the camera is following our ball and it falls okay so now we have to start adding the code to our pole so we can move it a little bit to the sides so let's attach script let's call it ball and the signal variable that is called movement speed and set it to 0.05 something really small and then we can modify it if we want and in the func process let's say with a user input if input is action pressed I'm going to use the default ones which are the arrow keys and every empty calibrate you have this but you can modify and create your own so let's start with you I left path so I don't get the error and let's copy this and you are right for the other one okay and now we can apply central inputs inputs will make that this node suddenly has from the center like some impulses makes it both magically you're not rotating anything you're just adding like some invisible force but since the ball is going to be rotating we're gonna see it rotate wherever we want it apply central impulse let's create a vector three in this case X is going to be movement speed the variable that we created and the rest is going to stay as zero and same is gonna happen in the other step instead of adding positive movement speed we're gonna subtract the movement speed let's try it out and see how it feels if we can move in pressing left right okay I made I made this on the other opposite side okay so this one has to be the negative and it'll has to be the positive Maya let's see okay yes I can move the ball now I can stop and here it goes and I think I forgot to add a collision there yes I forgot okay let's add use collision and I think that you can clear the level now so let's try that again okay and it goes there okay success however first level working let's now make this look a little bit better let's add some extras first of all if we add a texture to our ball we're gonna see it rotating better so let's start creating our material for that we got a close up here we select the rigidbody and remember that the mesh instance is what we are actually seeing and here on material we don't have anything that's a new special material see this new resource appears and when you click it you get all the options you have a preview and the one thing that we're going to be using on this tutorial for now is the albedo which is the color or a texture in this case if you modify the color you will see that the pole changes the color to whatever you pick in this case we can leave it on white and add this texture that we have here it can be whatever you like I like this one for this marble because it looks kind of okay and when you added you see that we have here our texture applied on the ball now when we play the game you see it actually rotating is now more clear because before it was white you couldn't tell the difference now I want also to have that glossy effect so let's modify this and add roughness let's move it lower lower lower lower so you see that it's kind of glowing the roughness basically means how a material is so if it's really smooth it reflects you will see here that it has has kind of this glassy so it looks kinda nice another thing that I see in a lot of these tutorials is that you see those sharp edges that you have around the object and especially when you're playing the game like you can see them those lines I don't really like them so I'm gonna go here on the project settings and on the rendering quality you can add the MSAA which if you played any game you know what this is you set it to 4 X for instance and every of those edges if you have a super sharp if you see here now you can see it even in the editor this makes it look so much better and since we don't really know exactly where we are and if we start creating complicated levels we need to have a better reference let's add some lighting so let's add a node and in special visual instance light directional light so you have these three kinds of lights they have very good description at the bottom so this is basically a Sun this is basically a light that you have in a point which is like a circle and this is a spot light which points to something if you want to have it just like a spotlight but we want just to have a Sun and whenever you create it you can see the difference between those I know if I can toggle yeah if you toggle you see that everything gets eliminated and this fake Sun that you add you can set the direction by the rotation of it so if we want to have the Sun having from one side pointing from one side you see this white arrow over there you can rotate it and you see how it moves let's do it at an angle and also a little bit looking down okay kind of like that I think that this position doesn't matter the only one that matters is the position of the arrow because the light is gonna be global it's gonna be affecting everything another thing that we would like to add is in this direction of light you can enable shadows so you press here on the shadow whenever you have this node selected you enable it and you see here they use the elements cast shadows to the other ones and this makes it look really good let's make the Sango from the top so okay so we can see the marvel right let's see how the game looks like right now okay start this look much better okay yeah you can also do the same to these platforms that we created here if you select one you can create different much different materials for them so let's go ahead and create a new special material and only change the color with LP let's make it something like light green something like this and if you want to reuse a material to different objects I recommend you to save the resource so I will save it as green material and you bring at this preview here which is really cute I like it that whether you have a lot of those you can set it and let's select the other ones so this one and here in material I can drag and drop so you set the material and here you said and on this one we're gonna leave it at white because I feel it's a better and the cold this is starting to look like a game I really like it another thing that you can change is the sky this is the default sky and if you don't know exactly where to modify it you have to do it on this resource that you have right here which is the default amp default environment you can make an image like FPS you know do you have those images of the sky like Sky box things like that or you can create a procedural sky which is the one that is created here on this default resource by setting the sky ground Sun texture whatever since this is really colorful let's add some some nice colors let's see so pink on the sky always looks nice horizon see I don't know maybe some green to make it more cool futuristic kind of surreal and oops I'm for the bottom color let's go with a dark purple purple let's see okay and or icing color let's go with something like a red ooh okay so let's make it a bit more darker okay let's play the game let's see how it looks like I wanna I want to feel how it looks here okay much better okay the level is super easy for now but yeah okay another one how cool sky a cool level I'm gonna cover the last thing that you might need in a smaller game which is checking whether an object is inside another one if you follow the other two tours in my channel you already know how to do this and if you've been seeing how easy everything here is it's because it's really super simple to create things since pretty Inga rod it's basically the same as you do it in 2d but you add an extra dimension which is the sea but the rest is pretty much the same in this case we're gonna be using an area and checking if something is inside that area or not the same as in the Box tutorials so we want to check on this node so let's create a new child node just going to be collision object area we have it here and as any other area you need a collision shape so let's add a collision shape inside of it and this relationship is gonna be a box shape this rectangle that you see there this box is how big it is so the same as before we use those sliders to make it bigger and let's make it a bit taller okay and it has some signals so the area has the body entered and let's create now a master script for our game as we always do and that's link that whenever in this let's rename these two and this area when a body enters that's connected to game let's add our rigidbody our player there our ball let's add it to a group so here in groups so we don't have to check for that instance and you can create as many marbles as you want there is a very popular to each game which consists in a lot of marbles going through a level which you can create a clone of that with all this knowledge like you don't really need that much for the physics stuff if you want to remove the player that's another story okay so now that we connected this on the game we check for if quality is in Group one don't remember if it was capitals or not yes it was capital letters okay print you want so you can replace this with a dialogue with men you going to the next level with whatever you like since I've covered that several times in my channel I'm not gonna create the entire thing so let's try it now that on the terminal there at the bottom it says u 1c speedrunning this already okay here you want you see Terry the message whenever we reach that area I don't like that it's doing that thing with the camera that it it's overlapping so let's modify this one maybe the last thing that you would like to know is that if you want to add some text elements or something controlled note related you can create a canvas layer which is going to make a new screen and inside that canvas layer you cannot control notes and here you can do the same as you did in any other tutorial here let's create a level which says hello from control nose and if you see here that the size of the screen on your canvas layer it will show up on top of your 3d game they will have it at the top so if you want to other thank you congratulations for finishing my level and trying this game whatever you can do it there okay so that covers all the basics now I want to try and make this level a little bit more interesting really like a time lapse of me editing this level and see how we can use these kind of basic shapes to create some interesting levels [Music] okay so I will play with the editor a little bit I created this level which basically makes the ball go at the beginning you have to move on the side this basically is like a tutorial for the game if you don't press anything you will lose but if you start moving you will notice that you can move that way you see that speed goes and goes very fast and then when you get this curve which is actually a bit longer than I wanted then you get to this part which you have to use these columns to make the ball go slower because otherwise you will go super fast and you will miss your target so this is something really busy you have to do but I know this of your extras that I want to cover here first of all the camera is not rendering all the distance so if you see here on the preview we cannot see the end of the level and since we don't have a lot of things on the screen let's make here on the fire let's make it longer okay so now this will show how much you see on the camera in this case we want to show all alone another thing is that I want to give that both the movement a little bit more impact so I'm going to rotate the camera a little bit so that makes you feel like you're polish rotating so let's go to the rigidbody and here let's get the reference as we did before with the camera to get this let's get the camera from this one so it's going to be get parent get no camera so we should with it bar sorry okay so okay we should get the camera over there and let's rotate it we want to rotate it in the white angle so camera rotate Y and this has to be / super-small I don't want it to be super strange so let's go with zero zero one and the same on the other side but as always to the opposite direction let's see if it's like this or not I'm confused now okay and I'm good okay yeah this adds more dynamism to the moving okay now you can feel that you're rotating the camera maybe it's even a bit too much let's make it rotate a little bit less it's good with zero five okay yeah this is more closer to what I feel that I'm pressing on the screen okay okay another website that you can go to your poll and maybe you want to make it go faster let's see the gravity scale here is one let's go I don't know let's try with three because this will make it tip the ball much faster so it's gonna be harder you see but it's I think it's more realistic than the other one the other one was super slow yeah now this is a challenge let's see how it reacts when I collide okay oof almost well okay yeah this one is much harder so you can tune these values here the gravity the weight of the object and anything and as before you can keep creating some levels and hope that this is useful for you to create any game on a game jam you can use these same principles to make a puzzle game or or even the same game that we did before with the box you can with the box pushing you can do it here in 3d and as you can see it's really really simple like God makes it really simple for you to to create 3d games in no time so at least for today and it was a lot to cover I hope I was able to make it as short as possible because I don't want to make things too complicated but I hope you enjoy it and I really want to thank my patreon and all your support if you are not subscribed please subscribe leave a like it helps the channel a lot and see you guys next time I will probably go back to one of the previous series and more updates on the dialogue system are coming soon so thank you very much again everyone for staying here and see you guys next time but [Music]
Info
Channel: Emilio
Views: 17,884
Rating: undefined out of 5
Keywords: Godot, 3.2, tutorial, CSGPrimitives, Camera, CSGShape, collisions, Player, Spatial Materials, Antialasing, MSAA, Light, shadow, sky, Environment, Area
Id: fdMOHMYslOY
Channel Id: undefined
Length: 33min 29sec (2009 seconds)
Published: Mon Jul 06 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.