that’s y code
void OnTriggerEnter2D(Collider2D collision)
{
Laser missile = gameObject.GetComponent();
missile =gameObject.GetComponent<Laser>();
if (missile)
{
health -= missile.GetDamage();
Debug.Log("Hit by a laser");
missile.Hit();
}
if (health <= 0)
{
Die();
}
}
void Die()
{
Destroy(gameObject);
}
}
but somehow my ship will not be destroyed .
my ship is Trigger and enemy laser collide with my ship on the matrix .
i read other people’s question too but the error is not the same