Ragdoll spazzes out.

Ok, so i have my ragdoll being instantiated at the player rotation and position when it collides with some electricity that comes out of my enemy, but when i do so the ragdoll goes crazy. goes into the floor and flails around. I am postion two images, one that shows the ragdoll components and one that shows it ones it’s instantiated.

[833-Screen+shot+2012-05-04+at+21.39.21.png|833]

I’ll show you the code as well

#pragma strict
var enableGUI : boolean = false;
static var beenKilled : boolean = false;
private var respawnPoint : Transform;
private var player : Transform; 
var ragDoll : Transform;
var playerReplacement : Transform;

function Start () {

 respawnPoint = GameObject.FindWithTag("respawnPoint").transform;	
 player = GameObject.FindWithTag("Player").transform; 
		yield WaitForSeconds(4);
		Destroy(this.gameObject);
}
function OnTriggerEnter (hitPlayer : Collider) {
	
	
	
	if(hitPlayer.gameObject.tag == "Player") {
			
		var deadBody = Instantiate(ragDoll, player.transform.position, player.transform.rotation);
		Debug.Log("ragdoll instantiated");
		Destroy(hitPlayer.gameObject);
		yield WaitForSeconds(1);
		enableGUI = true;
		beenKilled = true;
		
		
	}	
	
	
}

function OnGUI () {
	
	if(enableGUI == true) {
		
			Time.timeScale = 0;
			GUILayout.BeginArea( Rect(Screen.width/2, Screen.height/2, 200, 200) );
			GUILayout.BeginVertical("Box");
				
				GUILayout.Label("You Got Killed");
				GUILayout.Space(10);
				if(GUILayout.Button("Continue")) {

					if(beenKilled == true) {
			
						enableGUI = false;
						Time.timeScale = 1;
						Instantiate(playerReplacement, respawnPoint.transform.position, respawnPoint.transform.rotation);
						Destroy(gameObject.FindWithTag("ragdoll"));
						Destroy(this.gameObject);
						
					}
				}
				
				if(GUILayout.Button("Go To Main Menu")) {
				
					Application.LoadLevel("startScreen");
					Time.timeScale = 1;
				}
				
				GUILayout.EndVertical();
			GUILayout.EndArea();
		
	}
	
}

This usually happens when ragdoll colliders are “immersed” in another collider which has a rigidbody attached.

Usually you have this when:

  1. the ragdoll colliders intersect eachother because they’re too big.
  2. the physics matrix is not properly set, and so for example the ragdoll parts intersect the character controller or some other collider that encapsulates them.

The fix normally consists of making the ‘super’ collider a ‘Trigger’, so that it doesn’t act as a physical object.