The question is answered, right answer was accepted
Collider's codes works, while dont colliding..
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));
}
}
Answer by xxmariofer · Jan 18, 2019 at 08:54 PM
Can you Debug.Log just before the destroy and tell us if it shows something? if it doesnt is another problem not that one.
yeah its shows, that is ridiculous.
Edit: I checked tags too. Everything seems right to me :/
then is actually triggering, if its a public project or a project you can share i can check it if you upload it somewhere. If you want to try and get it yourself try and debug.log collision.transform.position for checking where the object is colliding and also the name of the object is colliding for checking whjere that object is in scene
iwas working on uploading to github, sorry for late reply friend.
https://github.com/batuhancicikler/top-down glad for helping ^^