コード例 #1
0
        private void OnCollisionEnter2D(Collision2D other)
        {
            if (!other.gameObject.CompareTag("Ball"))
            {
                return;
            }
            if (collisionName != "")
            {
                return;
            }
            collisionName = other.otherCollider.name;

            // Know which body of tower got hit
            var contact = other.GetContact(0);

            var damage = CalculateDamage(contact, other);

            Hit(damage);
            _damageIndicator.Spawn(Mathf.RoundToInt(damage), contact.point, contact.normal.normalized * -1, IsWeakPoint(contact));
            ProcessEffect(contact);
            ProcessAudio(contact);
        }