int groundLayerIndex = LayerMask.GetMask (Tags.Ground); Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition); RaycastHit hitInfo; if(Physics.Raycast (ray, out hitInfo, 200, groundLayerIndex)) { Vector3 target = hitInfo.point; target.y = transform.position.y; transform.LookAt(target); }
Ray ray = new Ray (transform.position,transform.forward); RaycastHit hitInfo; if(Physics.Raycast (ray, out hitInfo)) { lineRender.SetPosition(1,hitInfo.point); } else { lineRender.SetPosition(1,transform.position + transform.forward * 100); }
时间: 2024-10-12 20:43:00