Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

Game Programming Using Unity 3D Lesson 10: Ragdolls And Death.

Page 1 of 41

Game Programming Using Unity 3D

Lesson 10: Ragdolls And Death

Ferdinand Joseph Fernandez


Chief Technological Officer, Dreamlords Digital Inc.
Admin and Co-founder, Unity Philippines Users Group
November 2011

This document except code snippets is licensed with


Creative Commons Attribution-NonCommercial 3.0 Unported

All code snippets are licensed under CC0 (public domain)


Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 2 of 41

Overview
Again, we'll be continuing where we left off from the previous lesson. If you haven't done Lesson 9,
you need to do it before you can continue here.
We've gotten our characters to move and walk. Right now though, they just stand still when killed.
How about we make them fall down on the ground instead?
As much as “death animation” sounds like an oxymoron, that's what we'll be doing here.
Here's an even better way, instead of making a “Die” animation, we can let the physics do its job. The
character would fall on the ground using our physics system.
This is called a “ragdoll” effect, much so because its likened to a real world rag doll dropped on the
ground.

Creating The Ragdoll


Ragdolls aren't any different from other colliders in Unity. They are composed of the same colliders
that we've encountered. The only different thing with them is that they are composed of many
colliders linked together using joints. Joints connect one rigidbody to another.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 3 of 41

Illustration 1: Ragdolls are just made of capsules, boxes, and spheres connected to
each other.

Fortunately, Unity automates most of the process of creating a ragdoll for us, using the Ragdoll
Wizard. It will create all the necessary ragdolls, rigidbodies, and joints.
Select one of the zombie enemies.
Go to GameObject > Create Other > Ragdoll....
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 4 of 41

You'll see the Create Ragdoll wizard dialog.

Each slot in that window corresponds to a bone that we need to assign.


Expand the Enemy game object to show its child, the ZombieMixamo game object.
Expand it further to see all the bones in that character. In Unity, a 3d model's bone is also a game
object.
You need to drag the bone game object to the corresponding slot in the Create Ragdoll window.
The following image serves as a guide to help you understand which bone goes where.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 5 of 41

After assigning all the bones, go ahead and click on the “Create” button to finalize it. Unity then
creates all the necessary colliders, rigidbodies, and joints in all those bone game objects that we
specified.

Fixing The Ragdoll


Unity's ragdoll creator is not perfect, especially since 3d artists all have their own ideas on how bones
should be set up.
Sometimes, some of the colliders will end up in the wrong position. Select the “chest” game object.
You may end up seeing something like the following picture.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 6 of 41

The chest is actually that box you're seeing that's positioned in his abs. That box is meant to be on
his chest, not on his abs. So we need to reposition it.
Hold Shift. You'll see square dots show up on each side of the box. Those square dots are handles
that you can drag to resize and reposition the box.

Now go ahead and move the box up to his chest.


Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 7 of 41

Check the pelvis. Its box is probably in the wrong position too. So just move it down.

While we're editing the colliders, look at it in side view. The boxes could be in the wrong position at
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 8 of 41

that angle too.

That's it. But if you play the game now you'll see the zombie go haywire.

Illustration 2: Uh oh, looks like the zombie


is being possessed!
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 9 of 41

This is because the colliders of the ragdoll is colliding with our character controller.

Illustration 3: The big capsule is colliding


against all the other little shapes.

We need to tell Unity that the ragdoll colliders shouldn't collide with the character controller.
We can do this by grouping the ragdoll colliders in a different layer. Layers in Unity allow us to
separate objects from each other.

Making A New Layer


The first step is to move all the ragdoll colliders in its own layer.
First we'll make a new layer.
Select the Layers button at the top right corner of the Unity window.

A menu will pop-up. Select “Edit Layers...”


Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 10 of 41

The Inspector will show the Layer Editor. We have 32 layers in total, numbered from 0 to 31. The first
8 are reserved and can't be edited.
We'll add our own new layer in “User Layer 8”. Click on it and you can type in the name of your layer.

Type “Ragdoll” for the name.


Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 11 of 41

Moving Game Objects To A Different Layer


Now, select your ZombieMixamo game object.
The Scene View should show only the ragdoll colliders at this point.

In the Inspector, select the “Layer” property.


Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 12 of 41

Choose our newly added “Ragdoll” layer.

It should prompt a question. Its asking whether you want the children game objects to have their layer
property changed too. In this case, we want all ragdoll colliders to move to the new layer. Select “Yes,
change children”.

All the children game objects should have their layer set to Ragdoll now.

Now, for our character controller, it should be in its own separate layer too.
Use “User Layer 9” to make a new layer called “Character”.
Select the Enemy game object. This is the game object that has the Character Controller component.
Change its layer to use “Character”. This time, choose “No, this object only” when prompted so only
the Enemy game object will be changed.
So our character controller is on the “Character” layer, and the ragdoll colliders are on the “Ragdoll”
layer.
Now click “Apply” so all the other zombies will have the layer change.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 13 of 41

Preventing One Layer From Interacting With Another


What we need to do is, prevent everything in the “Character” layer from colliding with anything in the
“Ragdoll” layer.
Go to Edit > Project Settings > Physics.

The Inspector will show you all the settings for the game's physics. Among them is the ability to tell
one layer to stop colliding with another layer. This is the Layer Collision Matrix.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 14 of 41

Here we have rows of checkboxes. Each row or column represents one of the layers in Unity. You'll
find there our “Character” and “Ragdoll” layers.
In those rows of checkboxes, find the checkbox that intersects “Ragdoll” and “Character”. Uncheck it.

This means Unity will prevent objects in “Ragdoll” from colliding with objects in “Character” and vice-
versa.

Save Your Work


Now would be a good time to save your work.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 15 of 41

Disabling Ragdolls
If you test the game now, it still doesn't work as expected.

This is because the walk animation and the ragdoll physics is fighting against each other, wrestling for
control of the 3d model.
We need to tell the ragdoll physics to kick in only once the zombie is dead. That is, it should only go
limp like a rag doll once its dead. Until then, the 3d model should be controlled by the animations.
If you select the “pelvis” game object, you'll see it has a rigidbody. Actually, all our ragdoll colliders
have a rigidbody.
The simplest way to temporarily disable the ragdoll is to tell all those rigidbodies to stop interacting
with the physics engine. The way to do this is to check the “Is Kinematic” property.

Its not practical to have to check all those checkboxes by hand, so we'll do it by script.
Create a new C# script. Name it “Ragdoll”.
Put this code:

01 using UnityEngine;
02 using System.Collections;
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 16 of 41

03
04 public class Ragdoll : MonoBehaviour
05 {
06 void DisableRagdoll()
07 {
08 Rigidbody[] allRigidbodies = GetComponentsInChildren<Rigidbody>();
09
10 foreach (Rigidbody r in allRigidbodies)
11 {
12 r.isKinematic = true;
13 }
14 }
15 }
16

In line 8, we use GetComponentsInChildren. Take note of the plural, we're getting many components.
Here we are getting all rigidbodies in all the children of this game object.
In line 10, we simply iterate over all of them and set their isKinematic property to true. Like we said
earlier, we're simply automating the process of setting all their “Is Kinematic” property to true.
Next, we'll finally make use of this function:

01 using UnityEngine;
02 using System.Collections;
03
04 public class Ragdoll : MonoBehaviour
05 {
06 void Start()
07 {
08 DisableRagdoll();
09 }
10
11 void DisableRagdoll()
12 {
13 Rigidbody[] allRigidbodies = GetComponentsInChildren<Rigidbody>();
14
15 foreach (Rigidbody r in allRigidbodies)
16 {
17 r.isKinematic = true;
18 }
19 }
20 }
21

We'll call our DisableRagdoll function at the start.


Test the game now. The zombies should not exhibit any erratic behaviour now. Although
unfortunately, the ragdoll doesn't kick in anymore. So we'll add code to enable the ragdoll, but only
when the zombie dies.
Let's add the counterpart to DisableRagdoll, EnableRagdoll:

01 using UnityEngine;
02 using System.Collections;
03
04 public class Ragdoll : MonoBehaviour
05 {
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 17 of 41

06 void Start()
07 {
08 DisableRagdoll();
09 }
10
11 void DisableRagdoll()
12 {
13 Rigidbody[] allRigidbodies = GetComponentsInChildren<Rigidbody>();
14
15 foreach (Rigidbody r in allRigidbodies)
16 {
17 r.isKinematic = true;
18 }
19 }
20
21 void EnableRagdoll()
22 {
23 Rigidbody[] allRigidbodies = GetComponentsInChildren<Rigidbody>();
24
25 foreach (Rigidbody r in allRigidbodies)
26 {
27 r.isKinematic = false;
28 }
29 }
30 }
31

Pretty much the same thing, except it sets isKinematic to false instead.
Now we'll add the code to call this function:

01 using UnityEngine;
02 using System.Collections;
03
04 public class Ragdoll : MonoBehaviour
05 {
06 void Start()
07 {
08 DisableRagdoll();
09 }
10
11 void DisableRagdoll()
12 {
13 Rigidbody[] allRigidbodies = GetComponentsInChildren<Rigidbody>();
14
15 foreach (Rigidbody r in allRigidbodies)
16 {
17 r.isKinematic = true;
18 }
19 }
20
21 void EnableRagdoll()
22 {
23 Rigidbody[] allRigidbodies = GetComponentsInChildren<Rigidbody>();
24
25 foreach (Rigidbody r in allRigidbodies)
26 {
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 18 of 41

27 r.isKinematic = false;
28 }
29 }
30
31 public void OnDeath()
32 {
33 EnableRagdoll();
34 }
35 }
36

Our OnDeath function is meant to be called once the character dies. So we'll add the necessary code
to call this function.
Go to your Health script and add this:

01 using UnityEngine;
02 using System.Collections;
03
04 public class Health : MonoBehaviour
05 {
06 [SerializeField]
07 int _maximumHealth = 100;
08
09 int _currentHealth = 0;
10
11 void Start()
12 {
13 _currentHealth = _maximumHealth;
14 }
15
16 public void Damage(int damageValue)
17 {
18 _currentHealth -= damageValue;
19
20 if (_currentHealth <= 0)
21 {
22 Animation a = GetComponentInChildren<Animation>();
23 a.Stop();
24
25 Ragdoll r = GetComponent<Ragdoll>();
26 if (r != null)
27 {
28 r.OnDeath();
29 }
30 }
31 }
32 }
33

Instead of outright deleting the game object upon death, we just stop any animations being played.
This is to make sure the ragdoll physics will be the only one controlling the 3d model at the end.
Then we call the ragdoll's OnDeath function. That will enable the ragdoll physics.
That's it. Attach the Ragdoll script to your Enemy game object. Click “Apply” so the prefab is updated.
Test the game now. When you kill a zombie, it should fall on the ground properly.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 19 of 41

Unfortunately, you may find the zombie still following you even though its dead!
This is because the EnemyMovement script is still doing its job even though the zombie is considered
dead. We just add code to delete the EnemyMovement script when the zombie is dead:

01 using UnityEngine;
02 using System.Collections;
03
04 public class Health : MonoBehaviour
05 {
06 [SerializeField]
07 int _maximumHealth = 100;
08
09 int _currentHealth = 0;
10
11 void Start()
12 {
13 _currentHealth = _maximumHealth;
14 }
15
16 public void Damage(int damageValue)
17 {
18 _currentHealth -= damageValue;
19
20 if (_currentHealth <= 0)
21 {
22 Animation a = GetComponentInChildren<Animation>();
23 a.Stop();
24
25 Destroy(GetComponent<EnemyMovement>());
26
27 Ragdoll r = GetComponent<Ragdoll>();
28 if (r != null)
29 {
30 r.OnDeath();
31 }
32 }
33 }
34 }
35

GetComponent gets a handle to our EnemyMovement instance, which we pass to Destroy so it would
be deleted. In case GetComponent returns null (if EnemyMovement doesn't exist), its fine. If Destroy
is passed with the null value, it won't do anything.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 20 of 41

When you kill a zombie, you'll notice if you move to it you may find something blocking your way. Its
the character controller still standing there.

Its easy to fix this. We just delete the character controller once the zombie dies.
Add this code to the Health script:

01 using UnityEngine;
02 using System.Collections;
03
04 public class Health : MonoBehaviour
05 {
06 [SerializeField]
07 int _maximumHealth = 100;
08
09 int _currentHealth = 0;
10
11 void Start()
12 {
13 _currentHealth = _maximumHealth;
14 }
15
16 public void Damage(int damageValue)
17 {
18 _currentHealth -= damageValue;
19
20 if (_currentHealth <= 0)
21 {
22 Animation a = GetComponentInChildren<Animation>();
23 a.Stop();
24
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 21 of 41

25 Destroy(GetComponent<EnemyMovement>());
26 Destroy(GetComponent<CharacterController>());
27
28 Ragdoll r = GetComponent<Ragdoll>();
29 if (r != null)
30 {
31 r.OnDeath();
32 }
33 }
34 }
35 }
36
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 22 of 41

Adding Ragdoll To The Player


In preparation for letting the player be killed, we'll add ragdoll colliders to the player too.
Select the Player game object that we have on the scene.
Go to GameObject > Create Other > Ragdoll....
Same with what we did on the Enemy, we need to drag the corresponding bone game objects to the
slots in the window.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 23 of 41

Once you're finished, the player should end up like in the following image:

You'll see most of the limbs didn't end up with properly sized colliders. We just need to fix that.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 24 of 41

Let's start with the right lower leg. Find the right lower leg. Its game object should be “Bip001 R Calf”:

The capsule is clearly pointing in the wrong direction. If you look at the Inspector:

The direction is set to Y-Axis. That would be the green arrow in the previous picture. If the three
arrows don't look the same with the one shown in the picture, make sure you are using the Move Tool
in Local space.
We need it to point down, and based on the picture, you'll see its the red arrow, which corresponds to
the X-Axis.
So change the Direction to X-Axis.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 25 of 41

Its now pointing in the right direction. We just need to align it to the actual leg properly. If you look at
the Inspector again:

You'll see a property called Center, with X, Y, Z values. We need to reset it. So set all of them to 0.

The capsule should now be centered on the three arrows. Those three arrows, by the way, represent
the pivot point of the lower leg.
In the Inspector, change the Height to 0.47 and the Center X value to -0.235.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 26 of 41

We lengthened the capsule and moved it lower.

It fits the leg much better now.


Now we'll just make the capsule thicker so it gets the leg's shape as close as possible.
Hold Shift and you'll see green square dots on the capsule itself.

These are handles that you can drag to change the radius of the capsule. The ones at the top and
bottom of the capsule meanwhile, changes the height of the capsule.
Drag the square dot to increase the radius to about the same thickness of the leg:
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 27 of 41

Now, find the left lower leg. Its game object should be “Bip001 L Calf”.

You'll see its radius is too big. Same with what we did with the right lower leg, change the radius by
holding Shift and dragging the handles that appear.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 28 of 41

The height is a little too long so we'll adjust it a bit.


Same with what we did with the right lower leg, change the Height to 0.47 and the Center X value to
-0.235.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 29 of 41

Now on to the right forearm. The game object is “Bip001 R Forearm”.

It looks like it doesn't have a capsule. But if you look at the Inspector, it does have a Capsule Collider
component:

Unfortunately, the Create Ragdoll Wizard made the radius and height so small its actually close to
zero. That's why we couldn't see it.
Change the Radius to 0.07 and Height to 0.4.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 30 of 41

That's better. We just need to change its direction.


Again you'll see the red arrow is where it should be pointing, so set the Direction to X-Axis.

Now change the Center X value to -0.16.


Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 31 of 41

Next, the left forearm. It should be named “Bip001 L Forearm”:

Same with what we did with the right forearm, change the following:
Center: (-0.16, 0, 0)
Radius: 0.07
Height: 0.4
Direction: X-Axis
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 32 of 41

We only got a couple of things left to fix. Select the pelvis. Its named “Bip001 Pelvis”:

The box should be at his waist. Move it by holding Shift and dragging the handles.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 33 of 41

Last, select the upper spine. Its named “Bip001 Spine1”:

Again the box is at the wrong place. Move it upwards to his chest.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 34 of 41

Finally, our player ragdoll should look a lot better now:

Editing The Player Ragdoll


Same with all that we did to the zombie ragdoll, we need to put the ragdoll colliders into the “Ragdoll”
layer, and we add the Ragdoll script to the Player game object.
Select the child Player game object, not the topmost one.

Change its layer to “Ragdoll”. Choose yes when prompted to change layer of the children game
objects.
Select the topmost Player game object. Change its layer to “Character”. Choose no when prompted
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 35 of 41

to change the layer of the children game objects.


With the topmost Player game object still selected, attach the Ragdoll script to it.

Testing The Player Ragdoll


We should make sure the player ragdoll works properly. How about we kill the player off at the start to
see if the ragdoll works?

Adding Health To The Player


Before we can test this, the player needs to be damageable.
Remember our Health script? We're using that on the zombies.
Actually, we can also attach it on the player.
So go ahead and drag the Health script to your Player game object.

Now, add this code to the PlayerMovement script:


01 using UnityEngine;
02 using System.Collections;
03
04 public class PlayerMovement : MonoBehaviour
05 {
06 CharacterController _controller;
07
08 [SerializeField]
09 float _moveSpeed = 5.0f;
10
11 [SerializeField]
12 float _jumpSpeed = 5.0f;
13
14 [SerializeField]
15 float _gravity = 2.0f;
16
17 float _yVelocity = 0.0f;
18
19 // Use this for initialization
20 void Start()
21 {
22 _controller = GetComponent<CharacterController>();
23 GetComponent<Health>().Damage(999);
24 }
25
26 // Update is called once per frame
27 void Update()
28 {
29 Vector3 direction = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
30 Vector3 velocity = direction * _moveSpeed;
31
32 if (_controller.isGrounded)
33 {
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 36 of 41

34 if (Input.GetButtonDown("Jump"))
35 {
36 _yVelocity = _jumpSpeed;
37 }
38 }
39 else
40 {
41 _yVelocity -= _gravity;
42 }
43
44 velocity.y = _yVelocity;
45
46 velocity = transform.TransformDirection(velocity);
47
48 _controller.Move(velocity * Time.deltaTime);
49 }
50 }
51

We simply damage the player in the beginning with such a high value that he's sure to die. That way,
we can test if the player ragdoll works well. We'll just remove that code afterwards.
Test the game now. Its probably not working. Furthermore, you may get a bunch of errors in the
console window.

Remember we delete the CharacterController upon death so it won't block the way anymore.
Unfortunately, the PlayerMovement script is still trying to access it even though the player is dead!
Actually, PlayerMovement shouldn't be working anymore in the first place. We shouldn't be able to
move once we're dead, so we'll delete PlayerMovement upon death.
Open the Health script and add this code:
01 using UnityEngine;
02 using System.Collections;
03
04 public class Health : MonoBehaviour
05 {
06 [SerializeField]
07 int _maximumHealth = 100;
08
09 int _currentHealth = 0;
10
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 37 of 41

11 void Start()
12 {
13 _currentHealth = _maximumHealth;
14 }
15
16 public void Damage(int damageValue)
17 {
18 _currentHealth -= damageValue;
19
20 if (_currentHealth <= 0)
21 {
22 Animation a = GetComponentInChildren<Animation>();
23 a.Stop();
24
25 Destroy(GetComponent<PlayerMovement>());
26
27 Destroy(GetComponent<EnemyMovement>());
28 Destroy(GetComponent<CharacterController>());
29
30 Ragdoll r = GetComponent<Ragdoll>();
31 if (r != null)
32 {
33 r.OnDeath();
34 }
35 }
36 }
37 }
38

Run the game now. That should take care of the errors.
But the player ragdoll isn't kicking in. This is because the PlayerAnimation still keeps on playing
animations even after death. This shouldn't be the case, so we delete PlayerAnimation too.
01 using UnityEngine;
02 using System.Collections;
03
04 public class Health : MonoBehaviour
05 {
06 [SerializeField]
07 int _maximumHealth = 100;
08
09 int _currentHealth = 0;
10
11 void Start()
12 {
13 _currentHealth = _maximumHealth;
14 }
15
16 public void Damage(int damageValue)
17 {
18 _currentHealth -= damageValue;
19
20 if (_currentHealth <= 0)
21 {
22 Animation a = GetComponentInChildren<Animation>();
23 a.Stop();
24
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 38 of 41

25 Destroy(GetComponent<PlayerMovement>());
26 Destroy(GetComponent<PlayerAnimation>());
27
28 Destroy(GetComponent<EnemyMovement>());
29 Destroy(GetComponent<CharacterController>());
30
31 Ragdoll r = GetComponent<Ragdoll>();
32 if (r != null)
33 {
34 r.OnDeath();
35 }
36 }
37 }
38 }
39

Test the game. The ragdoll should work now.


However there seems to be a problem with the 3d model. Something is getting stuck.

Our ragdoll setup isn't actually proper on this one. For the ragdoll to work properly, all relevant bone
game objects should have a rigidbody. They should also be connected by joints.
However in our player game object, one of the bones doesn't have a rigidbody (and joint). Find the
“Bip001 Spine” (it should be the parent of “Bip001 Spine1”). That bone doesn't have a rigidbody when
it needs a one. This is because it connects the pelvis to the upper spine.
The spine in this character is actually segmented in two pieces: “Bip001 Spine” is the lower spine,
while “Bip001 Spine1” is the upper spine. Both of them should have rigidbodies and joints for the
ragdoll to work properly.
Make sure the “Bip001 Spine” is selected. Add a Rigidbody component. Also, add a Character Joint
(Component > Physics > Character Joint).
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 39 of 41

In your new Character Joint component, there should be a Connected Body slot.
Find “Bip001 Pelvis” in your player. Drag that to the Connected Body.

This means the lower spine is now connected by a joint to the pelvis.
Then we need to change the upper spine to be connected to the lower spine (by a joint again) now.
Select “Bip001 Spine1”. That is the upper spine.
It should also have a Character Joint. The Connected Body in this one should be pointing to “Bip001
Pelvis” right now. That's what we need to change. Find “Bip001 Spine” (the lower spine) and drag it to
the Connected Body.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 40 of 41

The player should fall on the ground properly now.

Now that that's taken care of, remove the code that damages the player so you can play properly
again.
Game Programming Using Unity 3D Lesson 10: Ragdolls And Death. Page 41 of 41

In Conclusion...
You've learned about joints and ragdolls. You also learned about making new layers and moving
objects to different layers. You learned about the handy layer collision matrix. And you also learned
that you can delete certain components and not just whole game objects.
In the next lesson, we'll make the enemies be able to damage the player.

You might also like