// Use this for initialization void Start() { ragdoll = GetComponent <RagdollManager>(); ragdoll.setRagdollActive(false); col = GetComponent <Collider>(); Alive = true; }
public void Shoot(RagdollJoint joint, int damage, Vector3 impactForce, Vector3 point) { // Particle effect where hit Quaternion particleRotation = Quaternion.LookRotation(impactForce, Vector3.up); GameObject particles = Instantiate(HitParticles, point, particleRotation); Destroy(particles, HitParticleTime); Health = Mathf.Max(Health - damage, 0); Debug.Log(string.Format("Shot for {0} damage", damage)); if (Health == 0) { // Ragdoll on death col.enabled = false; m_movingCharacter.enabled = false; m_movingCharacter.rigidbody.isKinematic = true; animator.enabled = false; ragdoll.setRagdollActive(true); Debug.Log(string.Format("Killed, force of {0} applied at {1}", impactForce, point)); joint.Body.AddForceAtPosition(impactForce, point, ForceMode.Impulse); } }