public override void processSecondaryHit(Item item, GameObject hit, Vector3 hitPoint, Vector3 direction) { if (current == null) { current = Instantiate(whalePrefab, (hitPoint + new Vector3(0, 15, 0)), new Quaternion()); current.setEffectValues(item, this); current.setPrimaryEffect(false); } else { Collider[] objects = Physics.OverlapSphere(hitPoint, blastRadius); foreach (var colliderObject in objects) { Rigidbody rigid = colliderObject.gameObject.GetComponent <Rigidbody>(); if (rigid != null) { AICharacter c = colliderObject.GetComponent <AICharacter>(); Vector3 displacement = colliderObject.transform.position - hitPoint; if (c != null) { c.gameObject.AddComponent <RagdollEffect>().startEffect(1.5f); c.takeDamage(0.5f * damage * Mathf.Clamp(1 - displacement.magnitude / blastRadius, 0, 1)); } rigid.AddForce(force * Mathf.Clamp(1 - displacement.magnitude / blastRadius, 0, 1) * displacement.normalized, ForceMode.VelocityChange); } } current = null; base.processSecondaryHit(item, hit, hitPoint, direction); } }
public void OnCollisionEnter(Collision other) { if (!shotForward) { return; } if (getLifeTimer() == null) { setLifeTimer(new GenericTimer(1, false)); } if (other.transform.root == transform.root) { return; } AICharacter c = other.gameObject.GetComponent <AICharacter>(); Rigidbody r = other.gameObject.GetComponent <Rigidbody>(); if (c != null) { r = c.childBody; c.takeDamage(50); c.gameObject.AddComponent <RagdollEffect>().startEffect(1); } if (r != null) { r.AddForce(other.impulse); } }
public override void processSecondaryHit(Item item, GameObject hit, Vector3 hitPoint, Vector3 direction) { Collider[] objects = Physics.OverlapSphere(hitPoint, blastRadius); foreach (var colliderObject in objects) { Rigidbody rigid = colliderObject.gameObject.GetComponent <Rigidbody>(); if (rigid != null) { AICharacter c = colliderObject.GetComponent <AICharacter>(); Vector3 displacement = colliderObject.transform.position - hitPoint; if (c != null) { c.gameObject.AddComponent <RagdollEffect>().startEffect(1.5f); c.takeDamage(0.5f * damage * Mathf.Clamp(1 - displacement.magnitude / blastRadius, 0, 1)); } rigid.AddForce(force * Mathf.Clamp(1 - displacement.magnitude / blastRadius, 0, 1) * displacement.normalized); } } base.processSecondaryHit(item, hit, hitPoint, direction); }