Monster shadow


Unity ragdolls! Make your characters floppy ;)

Ragdolls are awesome and fun! Activate ragdoll mode when your player dies to spice it up and make it more entertaining. I'll show you how to easily deactivate current systems and then activate ragdoll physics at the touch of a button or function call. ========= ❤️ Become a Tarobro on Patreon: ========= 🔔 SUBSCRIBE: 🗨️ DISCORD: ✅ MORE TUTORIALS:

Great tutorial, but when I use a rigidbody to move the player and I ragdoll, the spine1 bone glitches out.
I've think it has something to do with the animation, because when I changed the animation a bit with the spine1 bone, the problem dissapeared.
arturito productions
Super clear and easy to follow, thanks for the work
arturito productions
Maybe is good idea if you flip the camera horizontally so you turn your head where your cursor goes and not the opposite :)
Lol, you're right... Didn't even notice
Amazing content once again
Thank you :)
Armando Agra
Great video!
depro 1o1 Gaming
The thing didn't appear in the top right😐
That's weird. It appears for me on PC. I hope you found your way to the video, anyway :D
Thank you so much for this video. I have a question: could you make a tutorial for a 2D ragdoll camera that follows the player? I tried to make one the whole day and it didn't work.
Absolutely I can. I'll make that one next :)
Ragdoll physics make me go Yes.
@Tarodev yes
They make everything fun
Michael Pittino
Finding your channel is like finding a needle in a haystack. Pure Gold Content!
I appreciate it! Glad to have you on board.


in this video i'm going to show you how to turn your character into a ragdoll
this works whether you're using animation inverse kinematics or none of
the above as you see here in my unicycle demo
the player is going along using ik and then all of a sudden hits his
his body and ragdolls all over the place so what i've got here is just my 2d rig
it's got some bones and i've set up some ik with
it and then i've just animated it in this little idol state if you want to
learn how to do this i'll put a link up here um a little
annotation so go check that out but ultimately you can just ragdoll any
character that you've got it doesn't matter what it's doing
so i'll show you how to do that first what we'll do is we will expand all of
our bone hierarchy here and then i'm going
to grab all the bones so from the head the spine
the arms the legs and the feet then i'm going to add a
rigid body 2d to all of them i'm going to add
a capsule collider 2d and now if you'll see here i'll just
make this a bit bigger you'll see most of them are going in the
wrong direction so let's change the direction of the capsule
colliders to horizontal and then just as a basic rule what we'll
do is we'll increase the x we'll reduce the y to make them fit the
bones a little bit better and then we will change the offset to
kind of be roughly where they're all meant to be
now we'll need to do some little manual adjustments here so let's
start with the head with the head here i'm just going to
make it fatter and then i'm going to bring it up
a bit kind of just fit the head i'm just going
to be rushing here for the sake of the tutorial but you'll get the point
and let's check the spine so the spine down here that could probably be a
little bit fatter like that this spine too
then just do the rest for the rest of the bones make sure they're all lined up
correctly [Music]
all right next we need to connect them all with joints
so select all of your bones excluding your main bone so
right now this here is my my main root bone
so everything is going to be joining to that therefore that root bone
does not actually need a hinge joint so excluding the main bone
grab all the other bones and let's add a hinge joint 2d to them
like that that kind of looks a little bit funny now
starting down from the legs let's grab our foot
and then what we're going to do is we're going to connect this foot
to then this bone by a hinge joint so i'm with my foot selected i'm going to
grab the lower leg and just slide it into the
connected rigid body of the hinge joint and then from the lower leg i'll grab
the upper leg and then the upper leg will connect to
the spine and then i'll do the same for the other
foot just slide them in and then that to the spine and now
on the arms i've got my my forearm all connected to my upper arm
which then connects to the spine two so from there to there to the spine to
the upper spine there and i'll do that for the other one
one two and then my head will also be connected to my spine too
and then the spine two will then be connected to the spine one
just like that now that is effectively all you need to do
to rag doll your character now if i press play this is going to act
really weird not not exactly desirable now the reason
that is happening is because i have my ik manager attached so that's trying to
force the targets where they need to go and i've also got this animation
which is also uh trying to manipulate the rig so if i turn both of those off
and press play i've now got a super floppy rag doll
what we can do there like this this guy basically
destroyed his spine straight away so what you could do there
is on your spine two hinge joint connected to your spine one hinge joint
you could use limits uh and then you could change this from
something like something a bit more rigid like minus 20
to 20 and now it'll kind of just bend a little bit
pretty awkward still but um okay so now that we've done that
we need to actually activate this ragdoll in real time
so for example in my unicycle example we were going along
and there was no animation involved but there was ik pushing around and then
as soon as my head or my body hit something i would
collapse in a heap so we need to create a c-sharp script for that
so let's just call this ragdoll okay open up that script now what we're
doing in here is when we want to execute our ragdoll
we're just going to disable some things so for example i'm using animation and
ik so i'm going to disable those two things
and then we'll need to enable things like the bone rigid bodies and
the hinge joints and the colliders so let's get our references i will need
a reference to the animator
and then i'll need a reference to my list
of colitis i'll need my
hinge joints another list of the rigid bodies
and i'm also using ik so i'll grab a list of the uh
the limb solvers as i said before you may not need this
depends on your situation now we'll write a little function here let's call
its public void toggle ragdoll
and just to make it clear this takes a bull and we'll name it
uh ragdoll on so it's not confusing now what we're
doing in this function is effectively just
going through our list of components and enabling and disabling them
when we need so i'll actually move my face so i'm not in the way
so let's start with the animator i'm going to only have it
enabled when ragdoll is not on i'm going to disable sorry enable
my colliders only when i am ragdolling i don't want them on and colliding and
stuff when i'm like running animations and that sort of thing
uh i'm going to enable my joints i'm going to say joint enabled only when
we are ragdolling i'm going to go through our rigid bodies and say
rigidbody.simulated only if we are ragdolling and then
whatever else i've got solvers so i'm going to go through all of my
solvers now for the solver if you're using ik um
yes you can just disable the solver uh what i like to do
is just affect the weight of the solver because
even when you're ragdoling you still might want to be
applying just like a little bit of ik you know uh
just to make maybe make a like if it's still
holding on to uh like some handlebars on a bike or and you just want a rag dollar
body or you know whatever so i'm going to say if we are ragdolling um
then put it i i actually don't want any weight so i'm just going to put it on
zero but that there is an easy way for you to uh
you know have a little bit of extra control so
now when we first launch into the uh the game i'm going to
immediately say no we are not ragdolling and now back in unity
so on my root character i'm going to just drag in the ragdoll script
and then i'm just going to start putting in all of my references
so animator there and then i'm going to select
all my bones that and then just drag them into the
colliders drag them into the joints and drag them into the rigid
bodies and then my solvers just drag them into solvers
just like that and now we actually need a way to trigger this
so i've got this little toggle ragdoll button so i'm going to add a
event listener and just toggle ragdoll and mouse click now
obviously uh on my uni unicycle uh demo i
i would toggle this in script as soon as the head or the body there was no head
just the body would hit an object but for this
for demonstration purposes i'm just doing it via a button
okay let's give that a try so press play it's just dancing or idling or whatever
it's doing toggle ragdoll and he flops down now that looks a
little bit funky his spine is pretty much
snapping straight in half so if you don't want that you can go to your
spine to where these two join and you can go down to your hinge joint and you
can say use limits and let's let let's let's set this to
something a little bit more rigid so let's say minus 30 and
30 like that let's give that a try dansen and ragdoll and you can see
that's a little bit more rigid there a bit more lifelike is not kind of just
like suitcasing in half and if you notice
when he falls it's a little bit slow and floaty not
too realistic so what we could do is we could grab all
of the bones all of the rigid bodies
and just set gravity scale to something a little bit higher something like 2.5
and now if we try that yeah much better much more lifelike i mean
not perfect but see you could go through all of these
joints here and you could actually set limits so that it doesn't
fully collapse like this and make it a little bit more realistic
uh and to be honest you could go through and set different mass
for the body type so the the torso would be a little bit heavier than the forearm
for example so you'd set the mass to be equivalent and um you'd get more of a
more of a lifelike feel obviously i just went through and these
these colliders are not perfect so you know the longer
you spend on it the better the results going to be
but i hope you learned something i hope this has helped you in your
in your journey if it did leave a like subscribe
and i'll see you in the next video