private void OnTriggerEnter(Collider other) { // If we hit something damageable CS_AIBase damageable = other.gameObject.GetComponent <CS_AIBase>(); if (damageable != null) { // Damage and destroy damageable.TakeDamage(arrowDamage, shooter); Destroy(gameObject); return; } // If we hit another arrow if (other.GetComponent <CS_Arrow>() != null) { // Do this later return; } hasHit = true; m_rbRigidBodyRef.constraints = RigidbodyConstraints.FreezeAll; Collider[] colliders; colliders = gameObject.GetComponents <Collider>(); foreach (Collider collider in colliders) { collider.enabled = false; } }
private void OnCollisionEnter(Collision collision) { if (!hasHit && collision.gameObject.GetComponent <CS_Arrow>() == null) { CS_AIBase damageable = collision.gameObject.GetComponent <CS_AIBase>(); if (damageable != null) { damageable.TakeDamage(arrowDamage, shooter); Destroy(gameObject); return; } m_rbRigidBodyRef.useGravity = true; } }