[Godot3] How to use Blender Shape Keys in Godot | Game Dev Tutorial 11

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome back friends in this tutorial I'll show you why you may want to start using blender shape keys and how you can use them inside the Godot engine let's get to it I love being able to customize my player characters and video games and I'll spend literally hours finessing the settings to get the look I like and don't even get me started on how long it takes to pick a name but have you ever stopped to consider how much work was done behind the scenes to bring you so many options surely and in the solo developer couldn't possibly do all that work on their own well let me show you how straightforward it is to make shape keys in blender and how simple it is to use them in Godot there's a ton of info on shape keys on the web but I'd fail as a completionist if I didn't give you a little background about what a shape key is shape keys actually have many names depending on the software you use they can be called blend shapes or morph targets but in blender they're called shape keys in a nutshell every 3d object is made of a collection of points specified by vectors called a mesh this is our base mesh if we want our object to move in our game we need to move these points if our object doesn't need to change as it moves we can just apply a transformation matrix to every point in the object and it will move around our game world however if we want our mesh to change like to make a character run or do yoga we need to change the individual points of our mesh there are typically two ways to do this the first is to rigger object with a skeleton where we assign each point of our mesh to a bone then when we apply a transformation matrix to each bone the points assigned to it will move as well but the second way to move the points is to store a whole new list of positions one position for each point that we want to change the number of points in our mesh doesn't change but each point can be assigned many positions each unique list of positions is called a shape key the new positions of the shape key are relative to the base meshes position we can then have the computer interpolate between any two shape keys to provide intermediate positions traditionally shape keys have been used by animators to animate subtle changes like facial features and it is also often used to give players a lot of freedom to craft their own player avatar sometimes too much freedom these sort of things are fascinating to me but as a solo indie developer I really don't have time to be fussing over eyebrow angles instead I use shape keys to put variety into my games at a low cost if I make one model with a handful of shaped keys that changed the way the model looks that single model can become a virtually infinite variety of models in my game world and in today's demo I'll show you a simple example of just that but first I'll demonstrate how to make a model with the shape key and how to use it in Godot so it's time to head into blender first thing first I'll make us a unit sphere to experiment with and while I'm in object mode I'll apply smooth shading just in case I want to apply a cel shader later on on the right the green vertex looking icon is the context menu clicking on it shows you all the different kinds of data associated with our sphere object find the shape Keys section and in object mode click the plus sign this initializes the base key of our object which all of the shape keys will be relative to click the plus sign again to create our first shape key and double-click the key to give it a descriptive name to edit our new shape key make sure it is highlighted in the list and click the edit shape key icon then pull the value property all the way up to 1 the value property represents the interpolation value between the base key in the shape key now when we enter edit mode all our edits will be saved to the shape key I'll use proportional editing to make a funky morphs fear and here is my final result to move this asset over to Godot you can export it straight into a Godot project using the easting exporter plug-in see my previous quick tip video to learn how to get and install the II scene exporter in the exporter settings make sure export shape key is checked I also don't need any material data to be exported with this sphere so I'll set the material mode to none next we'll simply navigate to our Godot project and click the export to Godot button when our file is finished exporting close blender and Godot will auto import our file when it gains focus but I like to separate my II scene files into their individual components to do that I'll change the import settings and hit re-import so I don't have to work with the auto generated scene today's tutorial scene starts with a spatial root node and a camera let's add our sphere mesh instance to the scene and give it our iconic outlined material in our mesh instance inspector properties notice we have a new section called blend shapes open it to view the blend shape we made back in blender moving the slider between 0 & 1 interpolates between the base shape and the shape key but moving the slider manually isn't the only way to control the shape key value shape key values can be changed via animations and through scripts add an animation player to our scene create a new animation and a new property track on our spheres mesh instance node select the desired blend shape to animate in the animation editor I'll also quickly check the loop and autoplay on load settings so when we run our scene this animation will run and loop by default this animation will run for 1 second so at the time of 0 & 1 let's make a keyframe with the shape key value at 0 and at time 0.5 we'll make a keyframe with the shape key value of 1 [Music] to control the shape key-value from script take note of the tooltip as we mouse over the shape key it says the shape key is of a type property but when we look at the documentation for mesh instance it doesn't say anything about blend shapes but don't forget that the mesh instance class also owns all the properties and methods of the classes it's derived from in this case the method we want is inherited way back in the object class it's a method called set back in our script we'll use the set function to set the value of the blend shape property the set function needs the string that denotes the path of the property which we can find in the tooltip as we mouse over the shape key in this case the string is blend underscore shape forward slash morphs fear and finally we need to give the set function a value between the range of 0 and 1 to make things interesting let's give a random value so every time we run our scene the sphere will be a slightly different shape [Music] something you may not know about me my favorite holiday is Halloween so to celebrate I made this spider for today's demo but this is no ordinary spider model this is a shaped key spider model take a look at the blend shapes in the inspector we can change the abdomen size eye size leg length leg thickness mandible length and mandible size from just a single model one can generate a wide variety of spider types every time a spider is instance its blend shapes could be randomized and you get a unique spider but instead of doing that I've linked the spiders blend shapes to our friend the open simplex noise resource when I run the scene the Perlin noise values explore the spiders procedurally generated solution space if you want to take a closer look this demo scene and the previous tutorial is available for download on the day of the dev github page well that'll do for this tutorial thank you for your support and comments I love hearing from you if you learned something cool today consider hitting the like button and hit subscribe and the bell icon if you want to continue learning about game dev with us here on Dave the dev finally if you're curious about what I do between videos follow me on Twitter where I post frequent dev vlog updates hope to see over there and in the next video until then happy dubbing
Info
Channel: Dave the Dev
Views: 14,223
Rating: undefined out of 5
Keywords: Shape Keys, Blender, Godot, Godot Engine, Morph Targets, Blend Shapes, Spider, Procedural Generation
Id: ZJClHuIXRUM
Channel Id: undefined
Length: 9min 35sec (575 seconds)
Published: Tue Nov 05 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.