-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
카메라 및 특정 오브젝트에서 나오는 터치판정 및 pre충돌판정에 있어서 가상의 Ray를 실제로 볼 수 있게 그려주는 기능입니다.
3D 작업을 할때 터치 판정 디버깅을 하려고 사용했습니다.
public class RayCaster : MonoBehaviour {
void OnDrawGizmos() {
float maxDistance = 100;
RaycastHit hit;
// Physics.Raycast (레이저를 발사할 위치, 발사 방향, 충돌 결과, 최대 거리)
bool isHit = Physics.Raycast (transform.position, transform.forward, out hit, maxDistance);
Gizmos.color = Color.red;
if (isHit) {
Gizmos.DrawRay (transform.position, transform.forward * hit.distance);
} else {
Gizmos.DrawRay (transform.position, transform.forward * maxDistance);
}
}
}
Reactions are currently unavailable