关于2D的触发器OnTriggerEnter2D和碰撞器OnCollisionEnter2D,注意参数变量区别

    void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("OnTriggerEnter:" + collision.transform.name);
    }

    void OnCollisionEnter2D(Collision2D collision)
    {
        Debug.Log("OnCollisionEnter2D:" + collision.transform.name);
    }

注意触发器是[Collider2D collision],碰撞器是[Collision2D collision]

弄错了你就死活整不出来

你可能感兴趣的:(C#样例,unity3D)