void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { BasicController Player = collision.gameObject.GetComponent <BasicController>(); if (Player != null) // Если ссылка не пуста { Player.Hurt(Damage); // Вызываем метод урона и указываем его размер Instantiate(BOOM, transform.position, transform.rotation); Destroy(gameObject); } } }
void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == Target.tag) { BasicController TargetCharacter = collision.gameObject.GetComponent <BasicController>(); if (TargetCharacter != null) { TargetCharacter.Hurt(Damage); Instantiate(Explosion, transform.position, transform.rotation); Destroy(gameObject); } } }