Version: 2023.2
언어: 한국어

Physics2D.GetRayIntersection

매뉴얼로 전환
public static int GetRayIntersection (Ray ray, float distance, List<RaycastHit2D> results, int layerMask= Physics2D.DefaultRaycastLayers);

파라미터

ray The 3D ray defining origin and direction to test.
distance The maximum distance over which to cast the ray.
results The list to receive the results.
layerMask The LayerMask filter used to select which layers to detect Colliders for.

반환

int The number of RaycastHit2D results returned.

설명

Cast a 3D ray against the 2D Colliders in the Scene.

This function acts as a 3D "ray cast" but specifically designed to detect 2D Colliders. It achieved this by projecting the 3D ray into 2D space and then performs the 2D intersection test, ordering the results by the Z direction of the original 3D ray.


public static RaycastHit2D GetRayIntersection (Ray ray, float distance= Mathf.Infinity, int layerMask= DefaultRaycastLayers);

파라미터

ray The 3D ray defining origin and direction to test.
distance The maximum distance over which to cast the ray.
layerMask The LayerMask filter used to select which layers to detect Colliders for.

반환

RaycastHit2D The ray intersection result.

설명

Cast a 3D ray against the 2D Colliders in the Scene.

This function acts as a 3D "ray cast" but specifically designed to detect 2D Colliders. It achieved this by projecting the 3D ray into 2D space and then performs the 2D intersection test, ordering the results by the Z direction of the original 3D ray.