Ragdoll to Standing Improved! (Unity Tutorial)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys in a previous video we looked at how to make a ragdoll return to standing after a period of time one of the issues with the solution was that if the zombie fell on its front there was a noticeable flip before it stood back up in this video we're going to improve this by using different stand-up animations depending on the direction the ragdoll's facing okay we'll start with the scene that we created previously if you want to know how it was done take a look at our Ragdoll series alternatively you can download this project by supporting us on patreon all the links you need can be found in the description okay the first thing we need is a new animation for standing up when face down for this we'll head over to miximo.com first we need to make sure we have the zombie character selected then we'll search for a stand-up animation we'll download this one where the zombie starts face down we need to remember to select fbx for Unity and without skin we'll download this to the animations folder of the project okay let's switch back to Unity we'll select the new animation in the project panel then we'll select the rig Tab and change the type to humanoid for the Avatar we'll select copy from other Avatar and select the avatar for the zombie we'll click apply to save the changes then we'll go to the animation tab we don't want the animation to affect the position or rotation of the character so we'll bake all the transforms into the pose would also set all the based upon values to original to use the original values in the animation if any of this seems unfamiliar then take a look at our video on root motion where this is covered in more detail we'll also set the start frame to 100 so the zombie is already starting to push itself back up at the beginning of the animation we'll click apply to save the changes now we can add the animation to the zombie we'll open the zombies animator first of all we'll rename the existing stand-up state to face up stand up then we'll drag the new stand-up animation into the animator window we'll rename this face down stand up we want to transition from this to walking so we'll right-click and select make transition then we'll click the walk state to create the transition let's click on the transition and look at the preview at the moment there's too much of a delay between the zombies standing up and it's starting to walk we'll reduce the exit time to 0.6 so that it transitions to walking sooner we'll also increase the transition duration to 0.5 let's see how this will look okay that looks better next we need to alter the zombie script to use the new animation first of all We'll add some fields for the face down animation we'll copy the stand up state name field we'll prefix this one with face down then we'll right-click the original and select rename we'll prefix this one with face up we'll do the same for the clip names we also need a bones array for the new animation the final field We'll add is a Boolean to record whether the zombie is facing up or not we'll calculate this value in the Ragdoll Behavior method before we start standing back up will determine whether the zombie is facing up or down based on the direction of its hits if the forward direction of the hips has a positive y direction then it's facing upwards and will set the field to true now we just need to use the right animation based on this value first of all we'll go to the Align rotation to hips method in here we currently set the desired direction to the down direction of the hips if the zombie is face down we want the direction to be in the up direction of the hips instead so we'll change this line to set the direction to the up value then we'll check if we're facing up if we are we'll multiply the direction by -1 to set it to the down direction of the hips next we'll add a new method that gets the correct state name if we're facing up we'll return the face up state name otherwise we'll return the face down state name we'll add a similar method to return the correct bone transforms if we're facing up we'll return the face up transforms otherwise we'll return the face down ones now we need to make use of these methods we'll go to the resetting bones Behavior method in here we start playing the stand up animation we'll change this to use the new method so that it gets the correct state to play while we're here we'll also fix a bug that was pointed out in the comments previously if you shoot the zombie while they're standing up when they start to stand again the stand-up animation doesn't start from the beginning to fix this we can specify we want the animation to play from the beginning by adding the layer value of zero and a normalized time of zero next we'll go to the standing up Behavior method in here we're checking if the stand-up state is still playing before switching back to walking we'll replace the state name with the method so that it checks the correct one next we need to make use of the bone transforms of the face down animation we'll go to the awake method and initialize the array in the same way as the face up one then we'll call the method to populate the transforms using the face down clip name there's a slight bug in this method we need to change it to set the bone transforms passed in as a parameter now everything is initialized we'll go to the resetting bones Behavior method we'll use the new method we created to get the correct bone transforms based on whether the zombie is facing up or not this will now reset the bones to the correct animation the only other thing we need to change is when we align the position to the hips we need to use the correct bone transforms in here okay that's everything let's save the script and switch back to Unity we'll select the zombie in the hierarchy and set the values in the inspector we'll set the state names to match what we set in the animator the face up clip is called Stand Up and the face down clip is called standing up okay let's press play to try it out first we'll shoot the zombie in the head to check that the old functionality still works that still works the same as before now let's shoot it in the leg to make it fall forwards it now uses the new animation and looks much better in the next video in this series we'll look at how we can impale a ragdoll on some spikes if you want to be alerted when this one's out then subscribe and click the Bell icon if you have any questions or feedback on this video then please let us know in the comments a big thank you to all our patrons we really appreciate you helping to support the channel if you'd like to help and also get access to the source code you can find Details In the description thanks guys
Info
Channel: Ketra Games
Views: 6,646
Rating: undefined out of 5
Keywords: Ragdoll, Ragdoll Physics, Ragdoll Unity, Ragoll Unity 3d, Reverse Ragdoll, Reverse Ragdoll Unity, Reverse Ragdoll Unity 3D, Ragdoll to Standing, Revert Ragdoll Unity, Revert Ragdoll Unity 3D, Unity, Unity Tutorial, unity3d, Unity3d Tutorial, Learn Unity, Indie Game Development, Game Development, Learn Unity3D, Unity 3d, Unity Tutorials, unity 3d Tutorial, Tutorial, Game Development Unity, Unity Game Tutorial, Unity Tutorial for Beginners, Unity Beginner Tutorial
Id: 94ikwm4V6mE
Channel Id: undefined
Length: 10min 10sec (610 seconds)
Published: Fri Mar 10 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.