How to make better games using Curves in Godot | Game Dev Tutorial 6

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you hello friends welcome back to Dave the devs game dev tutorials today I'm gonna show you how to use godot's curve resource to improve your games and I'll be doing that with a rocket ship and at the end of this video I'll show you how I'm using curves in my new game prototype project route so let's get to it you may be thinking to yourself David why are you talking about curves that sounds incredibly boring well let me tell you if you want to level up your game making skills curves are one of those things that you didn't know you needed until you learned how to use them so what are curves really well a curve resource in Godot is basically just a function not a function in a programmatic sense but in a mathematic sense so I'm talking about a function where you input an x value and out pops a Y value mathematic functions are an extremely important concept to understand if you want to be a game programmer and it's probably a good idea to be able to make custom functions that follow required specifications but if you're someone like me it is sometimes difficult to have an intuitive understanding of how a function works just by looking at this jumble of symbols so instead of working with functions like this we can use godot's curve resource and work with functions visually like this the bottom horizontal axis represents your input X value and the left vertical axis as your output Y value in this way it is easy to understand what a function is doing and we can use this visualization to easily create custom functions by adding and manipulating points let's look at an example of how we can use a curve tool and SpaceX's Falcon 9 rocket this example project can be downloaded from the day of the dev github page linked below in the description the landed miss value is a value between 0 and 1 and determines how far along the process of landing we are the height value is just how far the rocket is above the pad and number of pixels at the moment we're not using a curve at all in this project so the curve output is directly connected to the landed miss so when I press the auto land button the rocket will land with a linear function this linear function certainly succeeds in getting our rocket from the sky onto the pad but it just doesn't look right if you take a look in the inspector notice that I've exported the land in this variable so that we can change it and take a look at the values along any point in the landing procedure let's take a quick look at the script attached to the root node and add a curve resource to our project we want to add a curve resource such that the landed s value inputs into our curve and outputs into the curve output variable first I'll declare a curve resource and I'll be sure to export it so that it's visible in the inspector second I'll connect the land Earnest and curve output values via the curves interpolate method the interpolate method takes in an input X and exports of value Y that is determined by the curve that we make visually in the inspector in the inspector locate our new landing curve select the empty field and select new curve right click on the graph to open a menu here we have the option to add a point or load a preset I'll select the linear preset for now I'll run the project and demonstrate the effect that the preset curves have on our Rockets landing using a linear curve our landed miss and curve output remain the same as if we didn't even have a curve at all however if we select presets such as ease in and ease out we can see that the landed miss and the curve output begin to change relative to each other this means that as the landed miss value proceeds from zero to one we have the ability to control the speed of the rocket at any given point using occur [Music] to change the curve you can drag the existing points around the graph and change their slope as well as add as many points as you would like to get the shape that you desire I should also note that the specific example of moving a rocket around the screen could also be done using the animation player but if what you're trying to do is simply interpolate between one value to another using a custom function a curve is probably what you want to use and is easy to quickly change because of the visualization in the inspector also you can make a change to the curve in the inspector while your game is running and immediately see the results [Music] once you get a curve the way you want it you can save or load it just right-click on the curve field to open the resource menu [Music] now that we understand a little bit more about godot's curve resource let's take a look at one of the ways I've used curves in my new game prototype that I've been calling project brute in this game world everyone lives in a giant plant you would play a traveller and the principal way of travel through this plant is via skydiving through it you can't see my fingers but I'm doing air quotes around the word sky I've been working on it for a few days and at the moment it looks like this in this project I use a curve to fine-tune how quickly the player reaches terminal velocity when falling through the plant world but the uses of curves are pretty much endless and they are especially useful for fine-tuning game feel do you need a dampening effect on your camera use a curve need to control the fade in and fade out between scenes you can use curves for that too the possibilities are endless well that'll do for this video thank you so much for watching I hope that I was able to show you something useful if I did consider hitting the like button and if you want to see more videos like this subscribe and hit the bell icon if you want to stay in touch and follow things that I do like project route look for me on Twitter via the link in the description below hope to see in the next video until then put those curves to good use
Info
Channel: Dave the Dev
Views: 30,484
Rating: undefined out of 5
Keywords: Godot, Godot Game Engine, Game, Development, Tutorial, Math Functions, SpaceX, Falcon 9, Game Prototype, Curve Resource, Curve
Id: gHT3jsCEiyA
Channel Id: undefined
Length: 6min 45sec (405 seconds)
Published: Sun Aug 18 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.