void OnCollisionEnter(Collision hit) { DamageGiver dg = hit.collider.GetComponent <DamageGiver> (); if (dg) { Destroy(dg); } }
public void TryTakeDamage(DamageGiver dg) { // Debug.Log ("dg.rig:" + dg.GetComponent<Rigidbody> ().velocity); if (directional) { // Vector3 dirToDamageGiver = (dg.transform.position - this.transform.position).normalized; // Vector3 dirToDamageGiver = dg.GetComponent<Rigidbody>().velocity; Vector3 dirToDamageGiver = Camera.main.transform.position - transform.position; if (!DirectionValid(dirToDamageGiver)) { return; } } TakeDamage(dg.damageAmount); DamageFx(dg); }
public void DamageFx(DamageGiver dg) { FX.inst.SmallExplosionDamageEffect(dg.transform.position); }