void OnParticleCollision(GameObject other) { int numCollisionEvents = part.GetCollisionEvents(other, collisionEvents); IRagdoll ragdoll = other.GetComponent <IRagdoll> (); if (ragdoll != null) { if (!ragdoll.GetIsRagdolled()) { ragdoll.Ragdoll(true, Vector3.zero); } } Rigidbody rb = other.GetComponent <Rigidbody> (); for (int i = 0; i < collisionEvents.Count; i++) { if (ragdoll != null && rb != null) { Vector3 force = collisionEvents[i].velocity / 5; ragdoll.ApplyVelocityToBones(force); } else if (rb != null) { Vector3 pos = collisionEvents[i].intersection; Vector3 force = collisionEvents[i].velocity; rb.AddForce(force); } } }
private void OnTriggerEnter(Collider other) { IRagdoll ragdoll = other.GetComponent <IRagdoll> (); Rigidbody rb = other.GetComponent <Rigidbody>(); Vector3 newDir = transform.up; if (ragdoll != null) { ragdoll?.Ragdoll(true, newDir * velocity); ragdoll.ApplyVelocityToBones(newDir * velocity); } else if (rb != null) { rb.velocity = new Vector3(rb.velocity.x, 0, rb.velocity.y) + (newDir * velocity); } }