Version: 2023.2
言語: 日本語

Physics2D.GetRayIntersectionNonAlloc

マニュアルに切り替える
public static int GetRayIntersectionNonAlloc (Ray ray, RaycastHit2D[] results, float distance= Mathf.Infinity, int layerMask= DefaultRaycastLayers);

パラメーター

ray テストすべき Ray を定義づける原点と方向
distance The maximum distance over which to cast the ray.
layerMask The LayerMask filter used to select which layers to detect Colliders for.
results 結果を受け取る配列

戻り値

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.