1 LineRenderer lineRender = this.renderer as LineRenderer; 2 //0代表起始点,这里是设置起始点position 3 lineRender.SetPosition (0,transform.position); 4 5 Ray ray = new Ray (transform.position,transform.forward); 6 RaycastHit hitInfo; 7 if(Physics.Raycast (ray, out hitInfo)) 8 { 9 //1代表终点,这里设置终点位置 10 lineRender.SetPosition(1,hitInfo.point); 11 } 12 else 13 { 14 lineRender.SetPosition(1,transform.position + transform.forward * 100); 15 }
时间: 2024-11-05 01:01:56