i have made a script with parts of the characterDamage.js
so there is a soldier and when i shoot him he will be destroyed and his ragdoll will be placed there but when i shoot him two ragdolls of him are appearing instate of one
here is the script i didn't found the mistake :(
var lIVES = 2;
private var HIT = false;
var RAGDOLL : Transform;
var SOUND : AudioClip;
function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag == "BULLET")
{
HIT = true;
}
if(HIT)
{
lIVES -= 1;
HIT = false;
}
if (lIVES <= 0.0)
{
DESTROY ();
}
}
function DESTROY ()
{
// Destroy ourselves
Destroy(gameObject);
// Play a dying audio clip
if (SOUND)
AudioSource.PlayClipAtPoint(SOUND, transform.position);
// Replace ourselves with the dead body
if (RAGDOLL) {
var RAGDOLL : Transform = Instantiate(RAGDOLL, transform.position, transform.rotation);
}
}