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.

Bug Error with raycasting and an AllHitsCollector when Burst is disabled

Discussion in 'Physics for ECS' started by PhilSA, May 24, 2021.

  1. PhilSA


    Jul 11, 2013
    In my game, there's a point where I do a raycast like this:
    Code (CSharp):
    2. RaycastInput castInput = new RaycastInput
    3. {
    4.     Start = startPoint,
    5.     End = startPoint + (direction * length),
    6.     Filter = characterPhysicsCollider.Value.Value.Filter,
    7. };
    8. tmpRaycastHits.Clear();
    9. AllHitsCollector<RaycastHit> collector = new AllHitsCollector<RaycastHit>(1f, ref tmpRaycastHits);
    10. collisionWorld.CastRay(castInput, ref collector);
    When Burst is enabled, everything seems fine. When Burst is disabled, I get these errors:

    The assertion that breaks is this:

    Visually, the raycast looks like the red line here

    When debugging right before the Assert, the "hit.Fraction" is 1f and the "MaxFraction" is 1f.
    1. Not sure how clear it is from the image, but the ray does intersect the box collider of the orange surface. In theory, its hit.Fraction shouldn't be 1f
    2. Is it intentional that the Assert is using a "<" instead of a "<="?
    Last edited: May 24, 2021
  2. steveeHavok


    Mar 19, 2019
    This has come up before and in the latest codebase that assert has been changed to "<=".
    I can't remember the details of the top of my head but I'll look up the PR that changed this.
    PhilSA likes this.