射线检测(Summary)

mac2022-07-05  35

1 1 //设置物体的Layer层级,在摄像机中设置camera.cullingmask,可以控制摄像机的渲染层级, 2 //用在射线上,可以控制射线碰撞什么,不碰撞什么。 3 2 4 3 //Raycast hit 5 4 RaycastHit hit; 6 5 LayerMask mask = 1 << 8; 7 6 void testRay(){ 8 7 if(Physics.Raycast(transform.position,Vector3.right,out 9 8 hit,100, mask.value)) 10   { 11 9   Debug.DrawLine(transform.position,hit.point,Color.red,1); 12 10 } 13 11 14 12 }

 

转载于:https://www.cnblogs.com/Cocomo/p/5733405.html

最新回复(0)