2,584
社区成员




void ClickOn(Vector2 pos)
{
if (player == null)
return;
Debug.Log("点击的坐标:"+pos);
Ray ray = this.GetComponent<Camera>().ScreenPointToRay(pos);
Debug.Log("ray:" + ray);
RaycastHit[] hits = Physics.RaycastAll(ray);
Debug.Log(hits.Length);
foreach (RaycastHit hit in hits){
//算出点击位置
BoxCollider bc = hit.collider as BoxCollider;
if (bc != null && bc.name.Contains("floor") && player != null){
//算出走动的方向和目的点,走动过去
player.GetComponent<Player>().WalkTo(hit.point);
break;
}
}
}