private void OnHitted(Collider collider, Vector3 point, Vector3 normal) { if (ignoreTags != null) { bool ignore = false; foreach (var t in ignoreTags) { if (collider.CompareTag(t)) { ignore = true; } } if (ignore) { return; } } var hittable = collider.GetComponent <IHittable>(); if (hittable != null) { if (Time.time < lastDamageTime + damageInterval) { return; } lastDamageTime = Time.time; var damage = new DamageData(); damage.amount = 1; damage.direction = transform.forward; damage.point = point; damage.normal = normal; DamageData[] damages = new DamageData[1]; damages[0] = damage; hittable.TakeDamage(damages); } }
private void OnHitted(RaycastHit hitInfo) { var hittable = hitInfo.collider.GetComponent <IHittable>(); if (hittable != null) { var damage = new DamageData(); damage.amount = 1; damage.direction = transform.forward; damage.point = hitInfo.point; damage.normal = -hitInfo.normal; DamageData[] damages = new DamageData[1]; damages[0] = damage; hittable.TakeDamage(damages); } Destroy(gameObject); }