Problem : Adding Force to Ragdoll , Please Help Me !

Hi everyone i use this code for enemy of my game but i have a problem in addforceing to enemy ragdoll : This code add no force to my ragdoll !!!

 function Detonate () {
	// Destroy ourselves
	// 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);
		DelAndForce (dead);
	}
}



function ApplyDamage(damage:int){
	Total_blood-=damage;
	if (Total_blood<=0  deadable_flag){
		deadable_flag=false;
		Destroy(gameObject);
		print(Total_blood);
		Detonate(); 
	}
	else{
		animation.CrossFade("Idle");
		print("enemy in Idle animation");
	    enemy.GetComponent("Seeker").StartPath(enemy.transform.position,enemy.transform.position);				
	}
}



static function CopyTransformsRecurse (src : Transform,  dst : Transform) {
	dst.position = src.position;
	dst.rotation = src.rotation;
	
	for (var child : Transform in dst) {
		// Match the transform with the same name
		var curSrc = src.Find(child.name);
		if (curSrc)
			CopyTransformsRecurse(curSrc, child);
	}
}



function AddForcetoRagdoll(){
		var hit : RaycastHit;
		var directionl = guncammera.TransformDirection(Vector3(0,0,1));
		
		if (Physics.Raycast (guncammera.position, directionl, hit)) {
		print(hit.rigidbody);
			// Apply a force to the rigidbody we hit information
			if (hit.rigidbody){
				hit.rigidbody.AddForceAtPosition(5000 * direction, hit.point);
				print(hit.rigidbody);
			}
		
			// Place the particle system for spawing out of place where we hit the surface!
			// And spawn a couple of particles
	}
}

How can i fix it ?

did you add regidbody to your enemy?!
without that it wont work, also try simple AddForce …

Apologies if I’m missing something, but do you actually call AddForcetoRagdoll anywhere? You don’t seem to be doing so in the code you’ve posted.

function DelAndForce (ragdoll:Transform){
	AddForcetoRagdoll ();
	print("Destroy");
//	Destroy(ragdoll.gameObject);
}
function AddForcetoRagdoll(){
      var hit : RaycastHit;
      var directionl = guncammera.TransformDirection(Vector3(0,0,1));
      
      if (Physics.Raycast (guncammera.position, directionl, hit)) {
      print(hit.rigidbody);
         // Apply a force to the rigidbody we hit information
         if (hit.rigidbody){
            hit.rigidbody.AddForceAtPosition(5000 * direction, hit.point);
            print(hit.rigidbody);
         }

the problem must be in this function…

// Place the particle system for spawing out of place where we hit the surface!
// And spawn a couple of particles
}

i add rigid body in child of Enemy game object, but i use this code in Gunscript and its work in any shot after crate rigidbody !!?

somebody help me :frowning:

I’m asking the same thing, again