Issue with colliders,Newbie question about OnCollisionEnter2D
Hi, I'm starting with Unity and C#, and I have a problem I can't resolve no matter how much I try to change the code. I have one player and one enemy, both with rigidbodies and box colliders, but they just collide and the enemy doesn't get destroyed. I've tagged "enemy" and "Player", and they aren't marked as triggers. Here is the code for the player:
void OnCollisionEnter2D(Collision2D _col)
{
if (_col.gameObject.tag == "enemy")
{
_col.gameObject.SetActive(false);
Destroy(_col.gameObject, 0.5f);
}
}
The thing is, I've created an Empty Object with a box collider with the exact same code, and it works. If you have any idea how to fix this I would really appreciate it,cause I want to get the essentials first before I continue. Thanks in advance.
Your answer
Follow this Question
Related Questions
Circle Collider 2d is slipping off box colider2d when it shouldnt 1 Answer
Collision check 0 Answers
Collision With Text 0 Answers
Collider Issue 0 Answers
problem with collider detection 0 Answers