20 lines
689 B
C#
20 lines
689 B
C#
using UnityEngine;
|
|
|
|
public static class PhysicsExtension
|
|
{
|
|
public static RaycastHit[] SphereCastAll(Vector3 startPos, float radius, Vector3 direction, float distance = float.PositiveInfinity, int layerMask = -5, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
|
|
{
|
|
var rayCastResults = Physics.SphereCastAll(startPos, radius, direction, distance, layerMask, queryTriggerInteraction);
|
|
|
|
for(var index = 0; index < rayCastResults.Length; index++)
|
|
{
|
|
var hit = rayCastResults[index];
|
|
|
|
if(hit.point != Vector3.zero) continue;
|
|
hit.point = hit.collider.ClosestPoint(startPos);
|
|
rayCastResults[index] = hit;
|
|
}
|
|
|
|
return rayCastResults;
|
|
}
|
|
} |