2D Ray 始终击中它所附加的 GameObject
2D Ray Always hitting the GameObject it is attached to
这条射线总是击中它所附加的游戏对象。即使以 float.MaxValue
作为距离,它也会击中它所附加的游戏对象。
RaycastHit2D rayHit2D = Physics2D.Raycast (transform.position, Vector2.down, Mathf.Abs(rayTransform.position.y));
Debug.Log (rayHit2D.transform.name);
if (rayHit2D.transform.tag == "Platform") {
Debug.Log ("ok");
}
看看this unity answers answer。您可以在 Physics2DSettings 中更改一个设置,让光线投射在碰撞体之外开始。
这条射线总是击中它所附加的游戏对象。即使以 float.MaxValue
作为距离,它也会击中它所附加的游戏对象。
RaycastHit2D rayHit2D = Physics2D.Raycast (transform.position, Vector2.down, Mathf.Abs(rayTransform.position.y));
Debug.Log (rayHit2D.transform.name);
if (rayHit2D.transform.tag == "Platform") {
Debug.Log ("ok");
}
看看this unity answers answer。您可以在 Physics2DSettings 中更改一个设置,让光线投射在碰撞体之外开始。