Ragdoll driven game

Ok, I’m working on a pvp based fantasy game with hit detection, and ragdolls. :slight_smile:

I got the following scenerio:

  • All player characters (later maybe the mobs too) are ragdolls.
  • The character animations are from Animator (with root motion, and physics).
  • In the start method I turn off the “ragdoll mode”.
  • When the character attacks any other character, I check if his weapon collides with any bodypart of the enemies body. If it is true, then I turn on the ragdoll mode.

Ragdoll mode on/off function:
First turn off/on the freezeRotation value on each rigidbody.
Then i turn off/on the animator component on the charater.

This works as I want.

Problem:
The main problem is, that in this scenerio, the characters can go through the walls.
Second problem: with root motion i dont know, how to create jump effect like with the character controller

What I tried to solve this
The following states are in ragdoll off mode.

  • Animation Root(true) + Ragdoll Rigidbodys Kinematic (true) = movement: OK, still goes through the walls, and can’t detect the collision between weapon and body part (becouse the last ones are kinematics)

  • Animation Root(true) + Rigidbody in the character root + Capsule Collider in the root = movement: crackling… and still can “crakling” through the wall…

  • AnimationRoot (true) + Kinematic rigidbody on the root + Caps collider on root = Movement is ok, walks through the walls.

  • Character Controller + Anim Root (false) + movement script + bodyparts capsule collider are active = movement is discontinuous and it tends upward. But cant go through wall.

  • Character Controller + Anim Root (false) + movement script + bodyparts capsule collider are’nt active = movement ok, can’t go through walls, but can’t detect the colloisoon between bodypart and weapon.

I know there are couple of solutions. I found URG!, I downloaded the free version, but it only creates a box collider on the chest (emergency collider if I’m not mistaken). It would be nice, but I don’t really want to spend money for this project yet.

In the other hand I want to improve myself, and learn how to do it. Yes, I’m masochist… :smiley:

So, if you have any advice or suggestion, pls tell me. :slight_smile:

This gives you the root motion plus additional control over the movements so that you can do jump.

void OnAnimatorMove ()
	{
		transform.position += anim.deltaPosition + jumpVelocity * deltaTime;
		transform.rotation = anim.deltaRotation * transform.rotation;
	}   

anim is a reference to the animator.

jumpVelocity is zero if not jumping and otherwise
jumpVelocity = mathf.Sqrt(2f * 9.82f * JumpHeight) - 9.82f * t;

Where t is time since character left the ground.
This will not work perfectly but it will get you started.

If you want a ragdoll game also take a look at this AnimFollow