Skip to content

Instantly share code, notes, and snippets.

View WolfVanH's full-sized avatar

Wolf Van Herreweghe WolfVanH

View GitHub Profile
@WolfVanH
WolfVanH / SuperSphereCastAllTool.cs
Created May 21, 2019 15:08
A workaround to handle sphere-casts not returning the hit point on initial the initial cast location
public static class Tools
{
public static RaycastHit[] SuperSphereCastAll(Vector3 startPos, float radius, Vector3 direction, [DefaultValue("Mathf.Infinity")] float distance = float.PositiveInfinity, [DefaultValue("DefaultRaycastLayers")] int layerMask = -5, [DefaultValue("QueryTriggerInteraction.UseGlobal")]
QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
{
RaycastHit[] rayCastResults = Physics.SphereCastAll(startPos, radius, direction, distance, layerMask, queryTriggerInteraction);
for (int index = 0; index < rayCastResults.Length; index++)
{
RaycastHit hit = rayCastResults[index];