2D Skeletal Character Rigging With IK In Unity 2020

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey how's it going everyone this is i am air and in this video i want to show you how we can use the tools built within unity to help out game developers who can't afford 300 for skeletal animating software and show you how we can set up a skeletal animation system within unity as well as have inverse kinematics set up to make moving and rotating these bones much easier and just to make sure i'm not wasting anybody's time with this video all we're going to discuss in this video is how we can set up the bones themselves as well as the ik or inverse kinematic points and in another video i'll show you how we can actually create animations using the tools within unity as well as how we can manage the different animation states and properly transition between them before we get started i want to discuss the advantages and disadvantages of using a 2d skeletal system as opposed to an alternative and animating the character by drawing out each individual frame yourself if you're not a very good artist like me drawing different animation states can take a lot of time and probably not look very fluid when you're done with it after spending all that time however i will admit that if you're able to draw your character frame by frame for animations you're able to have a lot more control of how each individual sprite looks within that character because you're not just simply rotating and moving sprites around you're actually drawing them exactly as you would have them intended for animations so the main advantage of using a 2d skeletal system is how much time you save creating animations whether you're good or bad at art a skeletal system will definitely speed up your workflow but if you want to have total control of every pixel on your character when animating you're gonna have to get really good at drawing first and then have a lot of time to draw out each animation frame it's really one of those decisions that you need to make as a game designer and simply ask yourself how much better will this game sell if i spend extra time hand drawing animations for every character on a game if you're a good enough artist and you have a good workflow this might not put much of a dent in your development cycle but if you're like me and you simply struggle with art i can rotate and position different sprites around to simulate movement probably hundreds of times faster than if i hand draw each individual frame one thing to also consider is how many characters do you want to actually have a skeletal system with maybe you only want a skeletal system for the player because generally the player is going to have a ton more animations than your standard 2d character in a video game and maybe for these other characters you can hand draw animations but like i said regardless of your skill level animations are going to be much quicker to make with a skeletal system as opposed to hand drawing each frame so without any further delay let's go ahead and get started with this video right now i have a very basic scene with the platform game object this platform game object contains two components first it has a sprite renderer component with the image of a square attached to it and it also has a default box collider 2d component as well the next thing we need to do is actually download some additional tools that don't come standard within unity to download these tools let's click on the window drop down at the top of the unity editor and then about halfway down that menu you should see a package manager option go ahead and select the package manager and a new window should open up as mentioned this window is going to contain different tools that you can use within unity some of these tools might have a green check mark next to them if you see a green check mark next to a tool that means you have it installed within your project there's going to be three tools that we need to download and we should be able to see two of them right now the two that we can see right now should be the 2d animation and the 2d psd importer let's go ahead and take this moment to download both of those packages and then install them within your project i already downloaded them and installed them for this video so go ahead and pause the video here if you need to download and install them once you have them downloaded and installed on your computer we need to download and install one more package and you probably can't see it right now because it's considered an experimental package and all that means is that unity is still developing it and it shouldn't discourage you from trying it yourself to see if it's a good fit for your project to show the experimental packages click on this cog icon right next to the search bar to open up the advanced project settings and then in this window go ahead and check off this box that says enable preview packages and now that we can see all the experimental packages let's go ahead and download the 2d ik package so if you need some time to download and install it go ahead and pause the video here with all the packages downloaded and installed let's go ahead and start working on the character if you don't have your own character to work with i made one specifically for this video there's a link in the description that will allow you to download from my google drive page go ahead and pause the video here if you need time to download it and this file is a psb file made in photoshop and the technique i'm about to show you requires that your character also be a psp file so if you're working with your own make sure you save it as a psb all we need to do is right click on the assets folder click on import new asset and then select whatever file you want to use to make a character with i've already imported the character that i'm going to be working with into the project so what we want to do next is select the character in the project window and in the inspector window about halfway down you should see this button for sprite editor go ahead and click on that and a new window should appear this window is showing you all the different sprites used to make up this character but lucky for us that psd importer package can recognize how this character is actually built within photoshop and individually put together these pieces to make the character whole but if you need to make any adjustments to the sprite size you would make those adjustments here but this character is well put together so we don't need to make any adjustments to the individual sprite sizes themselves what we want to do is go to the very top left of this window and click on this drop down that says sprite editor and then select the skinning editor tool i don't have time to go over all the different tools within this window in this video i'm going to focus more on getting the bones onto the character and then show you how we can set up inverse kinematics to control the bones a lot easier for animations so the first thing we want to do is actually create the bones for our character and you should see this vertical menu with different tools on the left let's go ahead and click on this create bone icon and of course we're not going to have to put 200 something bones in this character we're only going to be putting a few and what we want to do is place these bones wherever we want the character to bend and typically the first root bone will go on the pelvis area so i'm going to place it in this really awkward area right here and all i need to do is click the mouse once then just move the mouse into the position that i want the bone to end at and i'm going to put it at the very bottom of the chest here and then press the mouse button once again it should have created a bone and if you move your mass around you should notice it's making a new bone after you created the first one let's go ahead and have the second bone end at the bottom of the neck and then again go ahead and press the mouse button once to end the bone there and then we want to create the last bone all the way up to the top of the head after we create the third bone press the right mouse button to stop making bones next let's go ahead and click on the yellow chest bone after you click on the yellow chest bone it should look like a transparent bonus being made this is just letting you know that this bone is going to be a child of the chest bone we want to go ahead and place this fourth bone where the shoulder would be and then drag it down to the elbow and then from the elbow let's go ahead and drag it down to the bottom of the hand let's go ahead and repeat this process for the other arm on the character go ahead and right click on the mouse to stop making bones when you have the second arm finished and then we're going to do something similar for both of the legs but instead of using the chest bone as the parent we're going to use the first bone we made as the parent so let's click on the red first bone we made and then let's place this new bone somewhere right about here and then drag it down to where the knee would be let's click the mouse button to create a new bone and then drag it to the bottom of the foot right click after you make the second leg bone to stop making bones and then let's repeat this process for the other leg with all of our bones made what we need to do next is go ahead and weigh out the different sprites so in the vertical toolbar to the left let's click on the auto geometry button and then the small geometry window should appear at the very bottom right of this window go ahead and click on the button that says generate for all visible and that should give a lot of colors to your character what each of those colors represents is how much that individual sprite will be distorted when we rotate the bone around and what we want to do is make sure that only certain bones are going to react with certain sprites i'll show you what sprites and bones we need to fix so looking at that vertical left toolbar again let's click on the button says bone influence and then what we need to do next is double click on each individual sprite and make sure the correct bones are influencing it let's start with the torso so let's double click on the character's t-shirt another small window should appear at the very bottom right the torso sprites should only be affected by bone one two and three so let's go ahead and delete every bone that isn't bone one two or three by clicking on those individual bones within this list in the small window and then pressing this minus button at the very bottom right and as you delete each bone you should notice the color is changing go ahead and take your time to delete all those other bones next let's double click on the head sprite and this one should only be influenced by bones two and three you may not need to make any adjustments to this one moving along let's go ahead and click on the upper part of the right arm this one should only be influenced by bone four the bottom right arm sprite should only be influenced by bones four and five the upper left arm should only be influenced by bone six and the bottom left arm should be influenced by bones six and seven the right upper leg should only be influenced by bone eight the right lower leg should be influenced by bone nine and eight the left upper leg should only be influenced by bone ten and then the left lower leg sprite should be influenced by bone 11 and 10. now that we have the bone set up and the sprites weighted correctly let's go ahead and look at that vertical toolbar on the left and click on the preview pose button and then rotate the sprites around to see if everything looks good you might need to move some bones around depending on how the sprite rotates and to move the bones around go ahead and click on the edit bone button right beneath the preview pose button just to speed up this video i'm not going to worry about the placement of any of the bones but when i am making a real character it's a good idea to spend a lot of time making sure these bones are set up correctly because all your animations are going to be attached to these bones and if you make a bunch of animations and then change the bones after the animations won't work so go ahead and pause the video here if you need some more time to rotate your bones around and test them out but once you're satisfied with everything go ahead and hit the apply button at the top of this window and then we can go ahead and close this window out now let's go ahead and drag the character into the scene now and as you can see the character is way too big for this camera so i'm going to change the scale for the 2d character to 0.1 on the x and y and that makes it a lot easier to work with in the scene next we want to set up the ik points for our character which is going to make animating this character for you a lot easier so let's make sure the 2d character is selected in the inspector window and then let's click on the add component button and search for ik manager 2d and the ik manager 2d component let's click on this plus symbol and then let's choose lim a new child game object should appear on the bottom of the child game objects for the character and what we're going to do is we're going to make one of these limb solver 2ds for each of the limbs that we want to control we're going to make one for each hand each foot and then the top of the head so in total we're going to create five limb solver 2ds and then we want to name each of these new limb solver 2d game objects accordingly so for this first one we just made i'm going to name it right hand ik and i'm just going to go ahead and create all five right now and then we'll go ahead and set each one of them individually so go ahead and pause the video here while you go ahead and create the new limb solver 2d game objects and then rename them accordingly now one thing i need to mention before you pause the video for the head ik when you create the new ik choose ccd solver 2d instead of limb solver 2d a limb solver can only work with two bones while a chain ccd solver can work with as many bones as you want and for the head we want to actually control three bones instead of just two and that's why we need the ccd solver 2d for the head next we need to make some empty game objects on our player that are going to act as reference points for each of the limbs ik solvers and what we need to do is go ahead and expand all the bones out on the player and create empty game objects for the limb bones on each of the limbs and the limb bones themselves should be bone 5 bone 7 bone 9 and bone 11 and then the head ccd bone is going to be bone three so right now let's just go ahead and quickly make five empty game objects for those five different bones let's move each of those game objects to the bottom of each bone and then let's name each bone accordingly to what kind of ik it would be so for example for the empty game object on bone five i'm gonna name it right hand tip the game object on bone seven the left hand tip the game object on bow nine to right foot tip the game object on bone 11 to left foot tip and then finally the game object on bone three to head tip now we need to attach each of these game objects to its corresponding ik solver so let's click on the right hand ik game object and then let's drag the right hand tip game object into the effector slot for the limb solver 2d component and for both of the hands let's make sure we select this flip box and then hit create target and you should notice a little green circle at the bottom of the hand now as well as the bones themselves have some color to it now this little green circle at the bottom of the hand is the ik the green line symbolizes which of these bones the ik is going to be solving for and then we can actually have each ik manager have a different color if you want so if we click on the 2d character game object to bring it up in the inspector window this green box is letting you know what color that ik is it's not a bad idea to make each ik its own separate color but for now let's go ahead and make sure we set up the rest of the bones properly so let's do the exact same thing we did with the right hand ik for left hand ik but of course make sure you select the left hand tip game object instead of the right hand tip game object for the effector and also remember to hit the flip box for the left hand follow this process for right foot and left foot ik but for both of the feet we don't need to hit the flip button so remember to leave that one unselected now for the head ike go ahead and drag the head tip game object into the effector slot and then for this box that says chain length go ahead and input 4 and then of course hit create target and now we're finally through rigging our character as you can see it's a lot easier to control these bones and make animations with all this setup but animations are outside of the scope for this video and i'm going to go ahead and end this video here i'm going to follow up this video with another video that i'll go over animations and discuss how we can actually create animations within unity as well as control the different states based on what the character is actually doing if you found this video useful or you learned something from it please consider subscribing to my channel as well as following it up with a like for this video and one last quick thing that i want to mention i do offer a course on udemy that goes over everything you would need to know to make a metroidvania style game so if that's what type of game you're hoping to accomplish with this character you just created also consider purchasing my course on udemy and if you visit my website i have a special discount for the course that's enough self-promotion for this video though i definitely appreciate you watching it and hope all you all have a good rest of your day
Info
Channel: I_Am_Err00r
Views: 2,141
Rating: undefined out of 5
Keywords: Unity, Game Design, Game Dev, 2D Platformer, Indie Game Dev, 2D Character, 2D Character Rigging, Skeletal Animations, 2D IK, IK, Character Unity
Id: WgATop-S0LM
Channel Id: undefined
Length: 15min 48sec (948 seconds)
Published: Sun Nov 01 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.