Unity 2D碰撞检测

void Update()
{
    if (Input.touchCount == 1)
    {        Vector3 wp = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
        Vector2 touchPos = new Vector2(wp.x, wp.y);
        if (collider2D == Physics2D.OverlapPoint(touchPos))
        {
            //your code 
        }
    }
}

 

转载于:https://www.cnblogs.com/ninja9998877/p/4339036.html

你可能感兴趣的:(Unity 2D碰撞检测)