I am trying to make a replica of Asteroids in Unity. The problem is that my bullets are not triggering the OnTriggerEnter2D
method on the asteroids. The asteroi
The problem is the Spelling. The o
in onTriggerEnter2D
should be capitalized. Simple mistake like this one can ruin your day. I didn't even notice it until I ran your code.
void OnTriggerEnter2D(Collider2D collider)
{
Debug.Log(collider);
}
Next time if you are not sure about the spelling of the Unity callback function, right click in Visual Studio then click Implement MonoBehaviours search for the function you want, select it and click OK. Visual Studio will add that function for you.