[Unity] Physics.Raycast

APP 2019. 12. 6. 10:06

https://docs.unity3d.com/kr/530/ScriptReference/Physics.Raycast.html

 

Unity - 스크립팅 API: Physics.Raycast

Description Casts a ray, from point origin, in direction direction, of length maxDistance, against all colliders in the scene. You may optionally provide a LayerMask, to filter out any Colliders you aren't interested in generating collisions with. Specifyi

docs.unity3d.com

 

public static bool Raycast(Vector3 origin, Vector3 direction, float maxDistance = Mathf.Infinity, int layerMask = DefaultRaycastLayers, 
QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);

 

파라미터

origin The starting point of the ray in world coordinates.
direction 레이의 방향.
maxDistance The max distance the ray should check for collisions.
layerMask Layer mask는 레이 캐스팅 시에 콜라이더를 선택적으로 무시하는데 사용됩니다.
queryTriggerInteraction Specifies whether this query should hit Triggers.

Returns

bool 어떤 콜라이더와 레이가 충돌했으면 true, 아니면 false.

 

: