Animating a character for use in GameMaker Studio 2.3 | 3D Gravity Platformer [8]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

HE'S A WITCH!

👍︎︎ 2 👤︎︎ u/II7_HUNTER_II7 📅︎︎ Dec 07 2020 🗫︎ replies
Captions
[Music] [Music] [Music] so good morning let's make a character [Music] while i create my new player character in the background i'd like to talk about the state of 3d programming in gamemaker 3d games in gamemaker traditionally used to consist of only what you could draw with the d3d commands people used clever combinations of spheres cylinders blocks and walls and used the d3d transform commands to make the move most of the 3d games that were made in the gamemaker 6 era were tutorial edits with most of the code copied from the infamous doom tutorial times have changed nowadays all the 3d functions have been removed so there is no straightforward way to draw 3d primitives and to be honest i think this is for the better the threshold for getting into 3d programming has gotten a bit higher this is true but the fact is gamemaker is even better for 3d games now than it has ever been in the absence of official 3d support the community has been making libraries and resources to support the creation of 3d games and a lot of them are very impressive and greatly expand the functionality of game maker i want to highlight a couple of them in today's video and you'll find links to all of them in the description i'd like to start by recommending dragonite's youtube tutorials on 3d game development he has helped countless programmers get into the world of 3d with his clear and concise tutorials and this shows that there really is a market for 3d in game maker a lot of obj importers have been made over the years but none are as comprehensive as juju's obj importer obj is a format that is used for static models and the dot obj importer can be downloaded for free from juju's github link is in the description blue burns bb mod is without equal when it comes to importing professional models and materials into gamemaker among other things it lets you convert animated models in the industry standard fbx format to a gm friendly format and lets you draw them with advanced pbr materials alexander kondirev aka alticons has made an fbx importer in pure gml downloadable for free from the marketplace i will link to a couple of other interesting projects and resources as well including joe ellis's warp 3d which is a full 3d game development suite and igame arts dopefish which lets you load doom and hex and ward files personally i like using the tools and scripts that i've made myself through the years in this video i create my modeling blender and export it to obj then i will animate it in the smf model tool which is a free and open source animation system that i've developed for the last three years i'm still getting used to blender so i figured creating a character would be a nice exercise during the process i learned the hard way the importance of saving all the time i had to remake the texture from scratch three times because blender decided to crash i am far from an artist and the face needs some work but i'm happy with it for now and i can always redo it later okay so the character is done it was actually done a week ago but it's been a busy week and now it's time to make a move and the normal workflow for getting an animated model into a game engine is to animate it in blender and export to fbx however i'm going to use the smf model tool and that does not support any standard animation format so i am instead gonna export it as obj i'll save it as mushroom.obj and now i am actually done in blender so i can close that do i want to save yes i don't want to save and now i am in the smf topic at the gamemaker community and this is the main hub for the smf system so in the link section you can download smf version 0.9999 i keep talking online just to avoid that big version 1.0 so if you download this uh you get a zip file and i have not bought winrar uh so in here you can find the documentation and if you plan to use the smf system i recommend reading through this at least perusing it and this describes a little on how to use the smf model tool and how to use the scripts so that you can play your animations in game this file the yymps that is the local package so you can import this into a gamemaker studio 2.3 project there is also a version for 1.4 that is way outdated so you can use it but i don't recommend it but this is the latest version so i will extract the model tool and close this let's see here so this is the model tool and we have four views three of them are 2d one is 3d i'll go straight up into load model up here and let's load in the mushroom.obj that we just created so this will also load the relevant textures automatically so up here in the right corner you can see that we have three model indices one for the body one for the backpack and one for the hat i would like to combine the body and the hat so i'll select both of them right click merge selected yes so now the body is one model and the backpack is one also for my models i prefer to have them facing along the x direction so i will select both of these right now he's facing downwards along the y dimension so let's spin him around the z direction and that is perfect okay so when it comes to animating an object there are three steps one or at least for skeletal animation one you have to create the rig so if you notice up here we have four tabs that we can use and you have to use them sequentially and you can also move back and forth but the first thing you have to do is to create the rig and you can think of the rig as kind of the skeleton that is inside the object so if i for example create a node down here let's increase the opacity so this is a node that i have created and i will place that around there and let's create another node up there and notice how in between these two nodes you get what's called a bone uh and once you have created a rig you can go into the skinning section and that will tell the model how it should follow the rig so i'm gonna do this uh very quickly now first just to show you how easy it is to get a model to move and then i will go back and refine it later so i will just give this character a shoulder an elbow and a couple of feet [Music] okay so now we have a basic rig uh let's go into the skinning tab and for now i'm just gonna use the auto skin uh button here and that will automatically skin the entire model so that this bone for example only affects the vertices that are closest to it so let's go into the animation tab and create a new animation let's call this test animation and if i now use move node ik ik means inverse kinematics i can just click this node and drag it and the arm will move you can also do this in the 3d view but we do have to refine things because if i for example move the foot you can see that the backpack makes some nonsensical movement each vertex of the object can be mapped to up to four bones and that is why you can notice how only parts of the backpack are following this bone and that is because well maybe they are affected by other bones so this is how easily you can skin rig skin and animate a model but i want to go back here and i want to give i want to refine the skeleton so there are a couple of things i can do uh first i'm going to show you a way to optimize the skeleton and that is by removing this bone here because we don't really need that bone it's inside the character and it doesn't represent any real life bones so instead of keeping that i will detach it so now bone seven is still attached to bone one but there is no bone in between so that means that in the animation tool we can go to drag node and this node can be moved on its own another nice another nice thing about detaching bones like this is that the node uh node number seven is not even sent to the shader so this bone requires practically no processing at all and i will detach these as well so the shoulders and the hips they don't need to be bones and let's fix the arms a little bit because the bones are poking out of the arm it's kind of grotesque let's see there we go and let's give him a thumb as well this bone does not need to be attached but this one needs to let's see control in the 3d view it's not perfectly in the center there there we go now let's fix the other arm as well [Music] let us also create a bone for the backpack because maybe when he runs like the backpack will bounce back and forth so let's detach this node and then create a bone for the backpack okay and that's it for the rig now i have rigged everything that needs to be moved that needs to move actually let's see here let's make a separate bone for the hat as well just in case i'd like for that to like bounce back and forth when he runs okay so that's it for ringing now let's refine the skinning as well i will auto skin everything from scratch here so the process when it comes to skinning is basically to auto skin it first and then go through each bone and refine the weights now you do have some control over how the vertices are auto skinned because basically each vertex checks the distance to each bone and raises that distance to a power so the more um the closer a bone is the more weight it has and the higher this power is the more nearby bones are weighted so if i erase this power for example notice how this bone increases its influence right here while the influence is reduced in the periphery so if i increase this to 10 you can see that it's get it gets very concentrated right there let's use a power of say six for example for now so let's start with the hat [Music] there are a couple of tools down here you can paint weights directly onto the model so let's set the paint weight to one additive paint and we'll use triangle you can choose between either painting onto an entire triangle notice how there are three yellow points here those are the the vertices that will be painted to or you can paint to individual vertices and let's use triangle for now and a slightly larger radius and let's just paint the entire cap with a hundred percent weight now for this one uh this is the backbone and notice how there are like stray weights up here so i can remove those with subtractive paint i don't want the backbone to affect these vertices at all let's use additive paint and make sure that the face 100 follows the backbone i don't want the face to warp when when the character moves and let's test it let's see what happens if i for example rotate this bone okay that looks pretty unacceptable maybe the eyebrows should move a little bit with this so let's set the paint weight to like point 15 set paint radius 0 vertex now let's try again yeah that's pretty good okay so let's refine the arms as well let's go for the shoulder now the first thing i have to do is to remove the stray weights so i'll use subtractive paint and let's remove these i don't want the shoulder to affect these or all the way back there and there often are straight weights on the opposite side of the model and that is because of the normal weighting function i won't go into detail about that but that is useful for making sure that vertices inside this foot are primarily mapped to the bones that are inside the foot instead of the bones on the other foot so it doesn't check only distance it also checks normals um let's see okay so we have the left shoulder here i don't want the shoulder to affect the glove let's use paint type triangle and remove the weights on the glove there we go and i want to reduce the uh influence it has over the vertices on the on the body so you set paint i'll reduce paint weight to 40. 0.40 and let's go here and reduce these right actually let's reduce it to point yeah less than 0.3 and the nice thing about this is that when you reduce the weights or the influence for one bone the vertex automatically normalizes the remaining weights let's use subtractive paint and remove these so let's just test that see that i can rotate this and that does not look good at all uh let's move this bone over there and try again okay that looks absolutely terrible so that tells me that this bone needs a little more influence over here so let's give it 0.5 influence and use set paint there we go and let's switch to vertex and test again okay that looks a little better let's subtract these oh and these definitely and try again okay for a simple hand closing and opening i think that works okay i should have added more vertices to the hand if i wanted like precise hand movements but let's just keep it like this what happens if i move the thumb okay so that hand is done let's just save it as mushroom.smf and let's go into the other hand and fix that as well so i'll just do the same as i just did [Music] [Music] um let's fix the feet let's see here let's start with this bone and remove any nonsensical weights [Music] okay and does the front make sense as well yes it does how about this yeah it's starting to look good on this side yeah uh let's fix the backpack as well now the main body of the backpack should only follow that bone it's always additive paint [Music] let's see here wait i need to subtract this because i don't want the back of the character to follow the bone of the backpack let's just see what the backpack looks like looks like so if i for example move this bone i think the the strap of the backpack is yeah the weight of that is completely wrong i want to give it more weighted more towards the body so let's remove the body and test we use set paint let's see here actually i'll use additive paint because that is faster [Music] and for the let's see your left side i want to set the paint point let's set a point three for example [Music] uh let's also give the backpack bone some weight here this should have let's set it at 0.5 [Music] so if i move this bone the backpack moves like that uh let's unhide the body and test again so if i move the arm let's see here i think it affects the the strap a little too much [Music] uh let's test again all right [Music] yeah this is better and over here [Music] okay i actually think the skinning for this model is done let's see here [Music] just smoothing out this a little bit so okay so the skinning is done and it's time to make a simple animation i'll start by creating an idle animation and then i want to move his arms into a relaxed position beside his body maybe like that let's see yeah i'll leave it like that for now and i'd like to move his body a little up and down to like make it seem like he's breathing so i can actually grab this bone and move his body but i kind of want the legs to stay in one position and the way i'm going to do that is to select this leg and lock this node and this node and that means that this the locked nodes will always try to stay in the same position and if i then select bone or node number zero you can see that the legs stay where they are unless i move it far away so now i can move the body up and down and the the foot will stay in the same position i do notice one thing and that is that the foot is rotating a little too much so maybe i should actually add another bone and yeah let me just fast forward through this i'll add another bone at the foot okay there we go i'll toggle the grid again and try again and see what happens let's see here okay if i turn to turn off transform children [Music] then the leg or the foot will stay in the same position when i move the body let's see here [Music] okay so now i can dance perfect okay i'll clear this keyframe and start over move that i'll turn on transform children move this down there this down there and i'll turn off and i'll add another keyframe [Music] and i'll copy that and i'll add another one there i'll copy this and i'll add it at the center here so now the animation has four keyframes so let's make him look let's see here rotate local let's make him look to the left all right i need to enable this again i can look to the left there and then to the right here and some arm adjustments let's increase the animation time 1500 well that's a pretty good idle animation [Music] okay now let's add a run animation [Music] and i will copy the keyframe from the idle and paste that in here and just get rid of this okay so now we're starting in the idle position let's rotate it so that he looks straight forward there we go let's use ik to like get the rough bone positions so let's move one leg there and one leg back there let's see here i'll turn off snap to grid remove that there so when the left leg is pointing forward the right arm should also point forward and vice versa and since he's running he should lean a little forward there we go so let's copy this and paste it here and then we should just make it the complete opposite let's see here okay let's test this okay that looks pretty cerebral but let's continue copy this frame and add another in between frame here now i want the left foot to make contact with the ground like that i'll make the right foot look like it just kicked [Music] off [Music] do [Music] do do [Music] isn't this a beautiful walk cycle huh okay let's make him bounce a little up and down as well [Music] okay it doesn't look like running just yet but give it a little more time [Music] [Music] let's close his fist as well [Music] [Music] okay so this is where the leg connects with the ground so i want the backpack to swing to one side actually let's rotate the bodies as well okay now let's make the backpack swing a little bit so this is where you connect the crown [Music] [Music] [Music] okay and i also need to fix the backpack because the strap is going through so i want to move the backpack a little back there [Music] maybe rotate it around its own axis there we go and then we have this let's move it a little back some natural thumb movements as well okay so the animation is done it is time to save control s and i can close the smf model tool as well okay so the idle and the walking animation or running animation rather are done and i want to implement the animation into the game so i'm going to download the source from the previous youtube video and i'll save it as part eight so let's now all you need to do to import the smf system into your project is to drag this file into the project import asset package yes we don't really need everything in here we only really need this folder this is a folder containing demos and these are objects that are used by the demos so this is everything i need for my project and now this contains all the scripts that are needed for the smf system and let's also add the mushroom to included files so i have the mushroom here i can just drag that into the project would i like to add that as included file yes so now we have mushroom.smf there in the object system create event for the moment i use old system for both the system and the player and i will have to change that later but not today so let's load the model smf model load mushroom so now player model contains the handle for the smf model in the draw event instead of submitting the player vertex buffer i will want to do player model dot submit and that is all you need to do to draw an smf model but i also need to set the shader to i haven't given it a sample yet so it's not animated at the moment so i want to use the sh smf static and i can remove this so i think the player might be tiny but we'll see so he's facing backwards and that is because of this and let's make a new variable called var s scale is equal to let's scale it by 32 and see what that looks like okay that is way too big but you can see that the smf model contains the texture as well let's reduce this to 10 and in the z offset i want to subtract the player's radius so that he is drawn with his feet on the ground okay so now we have the player object in the game now let's make a move and the way i'm going to do that is by using what's called an smf animation instance so let's go back into the create event this is where i create the model instead of drawing the model directly i want to create the instance i'll call the first instance i create main instance and there are multiple ways to create an instance the old way which still works is to use smf instance create and then give it the player model the new way of doing it uses the new keyword keyword new smf instance and there really isn't much difference but well it looks cooler so now we have the instance here in the draw event instead of submitting the player model i would like to just to draw the main instance like that and let's use a shader that is compatible with animation luckily the smf system comes with a shader called sh smf animates okay and let's just test it so we should still get the player in t pose let's go to the step event and here i like to play the idle animation when the player is doing nothing and the walking animation when the player is walking so we have the input here h and v i'll rename them h input and v input and let's just make sure that these are correctly used like that so let's go all the way to the bottom here i don't want to mix animation and movement animate the player okay so if we have clicked either the um either the horizontal or the vertical buttons the easy way to do that to check is to do if and if not h input is equal to zero and v is equal to zero then i want to play the running animation that is main inst dot play run and for the animation speed i'll just put 0.02 for now lerp speed that defines how quickly it should switch from one animation to another if you set it to one it's instant uh let's set the point one for now reset timer this should always be false if you do it like this like if if you set this to true and then use this every step the animation will never really start because it's being reset all the time doing it like this will make it just play and continue playing so if we have not pressed any buttons let's play the idle animation instead and after doing this we have to update the the instance as well main install step and this function needs uh to know how quickly time should pass for most games you can just supply one but if you play around with delta time you can use that in here to make animations like make up for the delta time and we got a let's see here that is because of the rename up here of course it didn't work let's try again okay so now the idle animation is playing it's a little fast and let's see if the running animation works perfect and notice how when i start running and then stop he smoothly goes back to the idle animation okay now i would like to use the speed that i defined in the smf model tool the animation counter goes from zero to one zero being the start of the animation and one being the end so i want to find the time it takes for this animation to finish um so let's see here then i want to get the animation and that is the player model we can use the function called get animation and i should get the intellisense but i see that it doesn't appear but that requires an argument called name so let's give it the name of the animation uh let's get the time of the the the play time of the animation that should be anime.play time and let's create the animation speed so the play time is given in milliseconds and to find the final speed of the animation we need to do a thousand milliseconds over actually let's just get rid of this over that over the fps so that's game speed game get speed game speed fps there we go and let's use adam speed there and let's do the same here and this can be optimized of course um but i think this should be correct okay the running looks correct but i forgot to use that there okay so the idle animation looks correct okay this is starting to look very good let's increase the size of the player i think it's a little small that's a little big 13. [Music] okay so the next thing i need is a jumping animation so let us create a new animation i think i will do this fast forwarded forgive me isn't this a beautiful jumping animation huh okay let's save it saved save us mushroom yes let's exit and go into the included files here and replace this replace there we go now we should have a jumping animation as well and let's go into the step event and let's add a another if if not on ground wait isn't ground viable yes else so if we are not touching ground i would like to play the jumping animation [Music] jump okay and i want the lerp speed to be a little higher there 0.25 let's increase these slightly [Music] okay there we go [Music] hmm god [Music] [Applause] [Music] [Applause] you
Info
Channel: TheSnidr
Views: 2,722
Rating: undefined out of 5
Keywords:
Id: 8pikxeYFGMk
Channel Id: undefined
Length: 53min 45sec (3225 seconds)
Published: Sun Dec 06 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.