public override bool HandleCollision(ProjectileHead p, RaycastHit2D hit) { if (!IsIniFrame()) { // Handle being hit by a projectile p.HandleImmediateAbsorption(); GetHit(); return(false); } // Consider not being hit - let the projectile pass through return(true); }
public override bool HandleCollision(ProjectileHead p, RaycastHit2D hit) { // Ignore hit if generated inside defender - determine that by the hit normal and the collider itself if (hit.collider == TopCollider && (hit.normal - Vector2.down).sqrMagnitude < Mathf.Epsilon || hit.collider == BottomCollider && (hit.normal - Vector2.up).sqrMagnitude < Mathf.Epsilon || hit.collider == LeftCollider && (hit.normal - Vector2.right).sqrMagnitude < Mathf.Epsilon || hit.collider == RightCollider && (hit.normal - Vector2.left).sqrMagnitude < Mathf.Epsilon) { return(true); } return(base.HandleCollision(p, hit)); }