Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

RaycastNonAlloc not detecting BoxCollider in 2020.2.3f1 unless they have a Rigidbody

Discussion in 'Physics' started by FOXAcemond, Feb 8, 2021.

  1. FOXAcemond

    FOXAcemond

    Joined:
    Jan 23, 2015
    Posts:
    99
    Hello,

    I'm using RaycastNonAlloc in my code, and for some reason, since 2020.2.3f1, it doesn't detect BoxColliders unless they have a Rigidbody attached to them. I literally tried that in Play mode removing the rigidbody.

    The code hasn't changed since it last worked:
    Code (CSharp):
    1. Physics.RaycastNonAlloc(lastHit.position, lastHit.direction, collisions, laserLength,
    2.           ~0, QueryTriggerInteraction.Collide)
     
  2. FOXAcemond

    FOXAcemond

    Joined:
    Jan 23, 2015
    Posts:
    99
    This happened because I had a sphere collider with "Infinity" as a radius. Very weird but fair, Infinity values are risky when math calculations are involved.

    This should not fail silently though. There was 0 error in the console.
     
    Last edited: Feb 8, 2021