OnTriggerEnter2D is not being called

情到浓时终转凉″ 提交于 2019-12-02 04:56:10

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!