Godot 3.1: Creating a Simple 3D Game: Part 4 (Camera Follow, Lighting & Environment) #GodotEngine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Thanks!

👍︎︎ 3 👤︎︎ u/gatecrasher456 📅︎︎ Jun 08 2019 🗫︎ replies

nice, video like this help me week ago xD

about "Sky" and reflections, you can check my super simple video https://youtu.be/IQ-yw19xBQ8

👍︎︎ 1 👤︎︎ u/S48GS 📅︎︎ Jun 09 2019 🗫︎ replies
Captions
hello I'm walkabout for of creating a simple 3d movement dodge game using the Godot game engine my name is Colin and this video series we're creating this simple video game using the Godot game engine this is part 4 if you have not seen the first three tutorials in this mini series I'll put a link to those in this playlist on the screen right now but in this video we're going over four simple things to make your game look better and to adjust the way that the user sees your game first we'll look at viewport resolution in other words the window size of the game once you export it so the user can play it second we're gonna make the camera follow our player now there are many ways you can do this but there is actually a special kind of a camera node in Godot that will follow a character really nicely so we're gonna set that up to work really well third we're gonna look at lighting we're gonna add lights to our scene and adjust the shadows and lastly we're gonna look at the environment of our scene and change our sky color and we're gonna turn off an ugly blue castle this guy is currently casting onto our entire game creating this blue hazy look we'll get rid of that in this video but of course if you liked this video or learned something please go ahead and click on that like button close video it really helps me out and if you want to see more videos like this one in Godot or blender or technology click on that subscribe button as well and click on the bell icon if you want to get notified whenever I upload a new tutorial so let's go ahead and dive into Godot this is my project as I currently have it the first thing we'll do is we'll look at the viewport resolution not this viewport of the 3d workspace when we go ahead and play or export our game or test it out even by pressing the play seam button this window size for some reason Godot has a default resolution that means number of pixels across left and right and up and down of 1024 by 600 why it's that I don't really know it's not a very common a standard of resolution maybe it has to do with old Android tablets I'm not sure while closest preview and if I go up to project and project settings you're gonna see the project settings window and lots of tabs along the top but in the first tab if we scroll down on the left side to the section called display and window I was actually already there we're gonna see the size options for our screen so again it's 1024 by 600 is the default and by default the user can actually resize the window by dragging the bottom corner just kind of like that you might want to turn that off you might also want to have a border this window but that might make the game hard to close unless you actually program a quit option in your game which we're not gonna cover in this series so I would leave borderless off I think it's a less so it's a negative so yeah hopefully that's right 1 and I got change the width and height of my game window to 1280 by 720 that's basically 720p that's a standard size it's the standard aspect ratio of most computer screens nowadays or at least televisions anyways it's a 16 by 9 aspect ratio so if I go ahead and now press close and of course you can explore lots of these options for yourself and I go and play my scene we can now see and can I grab the corner no I can't but it's a bit bigger than this but more widescreen so now that we have this viewport size and we know what our player is going to see and we know their user experience let's window size next up is camera right now we have a camera in our scene and if we look in our node stack here or tree in our scene dock we're gonna see our camera notice right here and all you need to do to make your camera stick to your character is just drag it on to the character so I'll drag the camera onto Steve and we're done well are we well this will work but if I press the play scene button and as you can see now if I roll around the camera is following but it's being very rigid and in other words if I move left and right even slightly the camera follows with the exact same amount of movement it's a child of our character and that means that because children fall along with their parents at least in this hierarchical structure they will move exactly as my character moves now you might not want that and I would not suggest that that's not how most video games handle a following cameras cameras tend to move a little bit more in a relaxed fashion they have a bit of a delay and catch-up mechanism not catch up the food but they catch up to the player and kind of stick with it but they try to be more smooth than the actual action of the character so let's go ahead and see how we do that I'm gonna actually go ahead and select this camera and delete it from my scene believe it or not yet we're gonna get rid of the camera so I'll right-click on it over here and say delete nodes and press ok instead of having a normal camera object I'm going to select my level and I'll press the plus there is another kind of a camera object under spatial and under camera camera is actually a category there's another kind of camera object called interpolated camera and if you know what the word interpolated means in terms of programming interpolation has to do with different values on a scale specifically or more informally we can think of it as going from one value to another value in other words this interpolated camera can be told to kind of stick to or try to follow an object and it will gradually get there over time so I'm gonna select that press create gets put in the middle of my scene but I'll drag it up and drag it forward on the z axis so it's looking at the scene kind of like the old camera but now it needs an object to look at and actually with it selected in my scene dock if I look over here in the inspector its properties it has a target option and it's the very first option because it's most important it needs to know what object we're following so I'm going to assign it I'm gonna assign it to my Steve character now this is not actually gonna work and I'll tell you why if I press the play scene button we're gonna see the game starts off my camera is looking at my character oops you know what I forgot one option we've got to enable it here so I don't know why that's not enabled by default but it does need to be enabled and we press the play scene button you can see that the camera is zooming in and it's going right into the middle of the ball so if I move the ball though it'll actually move up and the camera will catch up to it this is obviously not what we want we actually want to make a secret invisible object behind the ball or above and behind the ball that the camera will go to and that secret hidden object is gonna be rotated a little bit pointing downwards out the ball and that secret hidden object will be a child of the ball and it will be the cameras new target so if I select Steve I'm gonna add that secret invisible object we're gonna use a basic spatial node the same as the root of our scene so with Steve selected I'll press the plus I'm gonna add a spatial it's the first one right there I'll press create and a spatial when you add it into your scene it basically acts like a coordinate in 3d space so if I move it up all we really see is this little box that's not really even there so I'm gonna move it up and forward on the z-axis and be able to play around with where it goes and I want it to not point straight forward I want to point down a little bit at the ball because that's how we're gonna want to see it and now I'm going to make the camera follow that object and said and as you can see when I selected the camera we can't even see where that object is this object by the way it's called spatial right now I might want to go ahead and double click and call it something like camera target okay so now I'll select my camera I'll go to the target option and I'm gonna select the camera target and press ok so now if I go ahead and press play scene or test scene we can see the camera zooms in and now it's looking at the ball quite nicely and I can move the ball around and as you can see the camera will kind of catch up to it I'm going back it gets getting too close to the camera but the camera will not really let it get too out of frame but then it will back up a little bit more even after that the ball stops rolling so this is quite nice if you want to adjust how fast the camera moves to keep up with your object that's an option and it's called speed and generally I like a speed of about five so I'll change that right there with the interpolated camera selected and I'll press the play scene button and we're pretty good one thing you might think about doing is you might think about making your camera be quite far away when you start your game and rotated to look at your scene as a whole before it zooms in and that way when your player starts your game or starts the level it will zoom in and maybe that fives a little bit high maybe I'd like three and let's try that again so that that way the user gets to see the whole scene before it moves in and you can adjust the speed as you see fit but that works quite well next up is lighting right now we have this ugly blue cast on our game from the sky and one thing that can help that just one thing that can help that is adding a light so I'm gonna go to my level select this top root node and I'll press plus yes there are three light objects or nodes that you can add under spatial lights can be found under the visual instance category and there they are lights and there are several kinds of lights directional lights on the lights spotlights directional lights are lights that cast everywhere in one direction just like the Sun that's why it's like honest little Sun so we're gonna use that one if you wanna have a small light in a scene that only casts for a certain amount of distance like it like a light bulb that would have a fall-off you might use an omni light but if I use a directional light and press create it's been added into my scene and for some reason it's pointing sideways so I'm gonna go ahead and get up and rotate it so it's pointing down and as you can see the light of my scene becomes a little bit less blue there is still blue light casting on my scene but now I have this white light that's brighter than the sky pointing down at my scene now this directional light does not have any shadows so if I select it over here in my scene dock and I go over to the inspector I have to enable shadow so under the shadow category I need to enable shadows and there we go we get shadows if you want to change the color of the shadows or actually the property of the light in other words the color of the light or the energy with a brightness of it we can do that so if I want to make the light a little bit let's say oh I don't know a little bit pinky I would just change that a little bit with the color picker so here we go now our lights just a little bit pinky or perhaps a little bit orange so so there you go that'll help counteract the color of the Sun but we're gonna do that when we change our environment anyways you'll notice that the quality of the shadows with a light won't necessarily be the greatest it will improve hopefully assuming that you're using a GL es 3 project you will see it improve a little bit if not substantially when you go ahead and test your scene out so now you can see in fact what I'm gonna do is I'm going to look at where my camera is it's over here and I'm gonna rotate my lamp so it's at a diagonal so we can see it better through the viewport in fact I'm gonna go ahead and rotate it so it's pointing more actually towards the camera so we get a shadow that we're looking at from behind it's a little bit better there our shadow settings under directional shadow if you have your light selected I'm not going to get into these but really what determines the quality of a shadow is the kind of light that you have we have a directional light but it also determines or the quality of the shadow is determined by what's called a split and there are three or four sections of a shadow depending on how far away from the lamp the shadow is so the closer you are to the light and the camera I believe and you're seen the higher quality of shadows and where it determines where to make lower quality shadows farther away from the lamp for the or the camera I'm really not sure are these split numbers and you can play around with these you can also attempt to blend the splits which means that you are trying to not make such harsh distinctions between different quality areas of shadows I believe if I understand it correctly you can play with these numbers but I would actually write down what these numbers are before you change them in case you mess up and need to change them back I will adjust the energy of this lamp a little bit so maybe it's at one rate now let's try to be 1.5 and turn it off and as you can see we get a brighter light or we could turn it down that's really up to you the last thing I might want to change or to do with my shadows or my light is the max distance that shadows will be drawn away from the camera the default is 200 but if you want to save some memory and some process setting powers and increase the speed of the runtime of your game you might turn this down what this max distance value means is how far away from your games camera shadows will be drawn so if I change this number to let's say oh I don't know 40 instead of 200 the default and I go ahead and play my scene we should see shadows in the game just fine but if I were to remove and roll my ball back if you look at this shadow being cast by the box it will eventually fade out and disappear if I get too far away from it and that's a detail but I might want to sacrifice to help my game run a little bit better especially on older hardware yes by the way my ball will not fall off the edge of my platform right now because we have not programmed gravity on the ball gravity is inherent with rigidbody objects like this box it fell down it tumbled what our kinematic body character does not have unless you program it in and as we come back closer to that box of course we see is shadow again okay so that is adding a directional light with shadows last but not least let's talk about changing the sky color and the sky light and the environment as a whole when you start a new Godot project you're actually given an environment resource to define this color if I move away from our pan away from my ground this color of sky including the Sun including the horizon color and the color that Phase two and the color of the ground and the color that it fades up to towards the horizon this resource is called an environment and you can actually see it right here default underscore env for environment dot T ar e s is an environment resource file in Godot and it comes with every new Godot 3.1 new project this environment is actually one that we're seeing right now in our viewport and environments are what you can specify per camera so if I go ahead and select my interpreted camera over here we're gonna see that there is a spot for an environment over here in the inspector and it's empty what I'm gonna do and what you actually could do is you could drag this environment over into the environment slot but I'm not gonna do that I'm gonna make a new environment and we're gonna customize the colors and the light color of the sky and then we're gonna make it actually appear not only in the camera which could be different than your editor viewport but we're gonna make it apply to the viewport as well so to make a new environment you select your camera go over to the inspector I've got an environment and we'll click on this little arrow and say new environment when you do that you get a bunch of new options in this little pullout section and if I expand background well I could have a clear color if I want it or I could make a new sky if I just leave it at clear color because this environment is now the one that's associated with the camera in my game if I press play scene I will no longer see the sky in my scene I will see this clear color which will show me the background or default color of my games viewport and there's no light coming off of that sky so we get this black so I don't want that I'm gonna make a new sky you can play on with other options but sky is good for a 3d environment and when you do that you get a bunch of options including what kind of a sky you want and again this is a resource that you can it'll expand out so you can change the options but we're not going to play around with a lot of these we are going to make a new sky for this mode sky that we just specified so right below that I'm gonna go to where it says empty and click the little arrow I'm gonna say new procedural sky when you do that and it makes a new procedural sky I can click on it it'll expand out this little resource within a resource really and we have options to change our sky and ground color including our our Sun so let's go ahead and explore these a little bit when I expand sky out under a procedural sky you can see we can specify the top and horizon colors of our sky so I could make my sky well I don't know a pink color and I make my horizon an orange yellow color now I'm not seeing this in my editor but if I go ahead and I press the play scene button you're gonna see that yeah you can see it in the game and our whole scenes being lit up with that color and if my camera wasn't pointing so angled down you would see that the sky is actually that color maybe I can go ahead and get my camera target and my camera target is over here and I might just lower it a little bit and rotate it so it's not quite such at an angle and let's go ahead and play the scene again and so now you can see my wonderful sky color don't worry about the color being cast we can change that as well so I'm going to select my camera again and now we can see these options again I'm gonna change the ground color as well so we're gonna make it maybe a dark purple II blue color kind of like that and maybe up towards the horizon we're gonna make it look a little bit more Orange II to match the the color of the bottom of the sky at the horizon so let's go ahead and see what that looks like and that looks really psychedelic now if you want to change the light coming off of the sky you can do that as well that is not an option of the procedural sky so I can go ahead and collapse that section where our colors for the sky and the ground were it's actually a setting called ambient light in the entire environment option so if I collapse background again here that procedural sky was that resource within a resource the next section down is called ambient light and there is a slider for sky contribution this is the the color how much the color of the sky contributes to the color of my scene so if I slide this down well I'm not gonna get that influence of the color on my scene from my sky so instead what I can do is well if it's black we're not gonna get much ambient light at all so if I play my scene it's gonna probably look quite dark instead what I'm gonna do it but you know what that green of the ground looks really really green in life it's the actual color what I can do instead is change the ambient color from black up to let's say white or maybe a lighter shade of grey so now that shade of grey will be the light coming from all sides of our environment so if I go ahead and press the play scene button our game is brighter again it's white or light gray light coming from all sides but we have a nice color of sky if I move around it looks pretty good what I might do in this case is just make this a little bit pink kind of like that just to give it that nice hue that make it look like the game fits in with the sky a little bit better but you know what I want to see that sky that I just made in my inner why am I seeing this blue sky won't actually see what my game looks like what I'm gonna do here is take this environment but I have made through my camera's property settings in the inspector dock and I'm going to save this environment as a resource so I'm going to click next to the word environment and I'm going to save this environment as a dot tra ES file we have this default underscore env TRS that's the blue one that we have in our viewport I'm gonna save this one as new underscore env and click Save and it is now rate they aren't just me in my project folder I probably should have organized it but oh well and up in my project settings under project project settings I can go to under where is it it must be somewhere under this first general tab and then if I scroll down I will find one under rendering and environment and here is the default environment for a 3d scene default env TR yes the blue sky the one that's down right here and if I click on the folder I can select new env and press open and press close and now you can see I can see that environment in my editor so as you can see you can have multiple environments depending on what camera you're looking through in your game which is a pretty cool feature and you can actually see that same environment if you save it out up to a resource in your viewport so let's go ahead and test this out I should now see the exact same thing in my report that I see in the game and that looks pretty good that will be it for this video thanks for watching if you like this video if you learned something go ahead and click on that like button below this video it really helps me out if you wanna see more videos like this one in Godot or blender or technology click on that subscribe button as well and click the bell icon to get notified whenever I upload a new tutorial check out my facebook page at facebook.com slash born CG on that page I post previews and sneak peeks of what working on next but that'll be for this one thanks for watching bye you
Info
Channel: BornCG
Views: 53,850
Rating: undefined out of 5
Keywords: Blender, tutorial, lesson, 3D, model, modeling, modelling, beginner
Id: j2wBsb-W3Ls
Channel Id: undefined
Length: 24min 29sec (1469 seconds)
Published: Sat Jun 08 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.