force before ragdoll

I have a character that has a head collider on it, so when it is shot in the head, it accesses another script that turns it into a rag doll.

below is the part of the script that receives the shot and sends it upward. I tried a few things, but didn’t have any success.
below that is the part of the other script that has the detonate function.

	if(hit.collider.gameObject.name == GameObject.FindWithTag("HeadCollider").gameObject.name)
		{
			hit.rigidbody.AddForceAtPosition(force * direction, hit.point);
			//AddForceAtPosition(force * direction, hit.point);
			Debug.Log("That was a headshot");
//			if(hit.rigidbody)
//			{
//					hit.rigidbody.AddForceAtPosition(force * direction, hit.point);
//			}
			
			
			hit.collider.SendMessageUpwards("Detonate",SendMessageOptions.DontRequireReceiver);

function Detonate () {
	// Destroy ourselves
	Destroy(gameObject);
	
	// Play a dying audio clip
	if (dieSound)
		AudioSource.PlayClipAtPoint(dieSound, transform.position);

	// Replace ourselves with the dead body
	if (deadReplacement) {
		var dead : Transform = Instantiate(deadReplacement, transform.position, transform.rotation);
		
		// Copy position & rotation from the old hierarchy into the dead replacement
		CopyTransformsRecurse(transform, dead);
		
		
	}
	
	
}

Make sure that it is being turned into a rag doll (dead body) before the add force by putting

hit.collider.SendMessageUpwards(“Detonate”,SendMessageOptions.DontRequireReceiver);

BEFORE

hit.rigidbody.AddForceAtPosition(force * direction, hit.point);

Hope this helps! :smiley: