Hey friends, i have a triggerenter2d code like; when triggerenter2d, hp -=10…
But i try fire to empty space, target and the projectile didnt touch eacy other, didnt collide, didnt triggered but target’s hp is dropped.
Are anybody have an idea about this?
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == "Enemy")
{
Destroy(gameObject); //destroys the projectile
enemy1.hp -= 5 + (UnityEngine.Random.Range(player.dmg * 7/10, player.dmg));
}
}