Search Unity

Assertion failed: Invalid AABB a

Discussion in 'Scripting' started by laurentlavigne, Apr 29, 2020.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    what's that?
    double clicking on the error does nothing
    it's in 2017 LTS
     
  2. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    and also
    Assertion failed: Invalid AABB aabb
    Assertion failed: Invalid AABB rkBox
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    That's the exact error text? Can you post a screenshot?
     
  4. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    also this
    Assertion failed: Assertion failed on expression: 'IsFinite(outDistanceForSort)'
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    there are no IsFinite in my code

    also
    Assertion failed: Invalid AABB rkBox
    Assertion failed: Invalid AABB aabb
     
  5. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    yes that's the exact text, nothing more in the console when selected :/ and they all come in bunch
     
  6. matkoniecz

    matkoniecz

    Joined:
    Feb 23, 2020
    Posts:
    170
    Oh, this one. Unity complains that you have invalid geometries.

    https://answers.unity.com/questions/1359216/random-invalid-aabb-inaabb-error.html suggests that it may be caused by feeding invalid data to transforms ("you have a script which divided by zero, then tried to assign NaN as a position to one of your transforms").

    https://www.reddit.com/r/Unity3D/comments/4marrd/invalid_aabb_a_error/d3u9mgi/ mentions that

    > the "Invalid AABB" error can be caused by a number of things, most often it has something to do with objects scale, in your case since the objects scale becomes infinite the engine cannot compute it's AABB, hence the error. So to fix it you must find out why the objects grow infinitely. The problem definitely lies in computing and recomputing the transform variables, probably the localScale gets messed up in the act of parenting the objects. Sorry I can't be of more help, but it can be any number of things causing it...

    Sadly I have no really good idea how to fix this family of errors beyond:

    1) googling for checking whatever you are using common sources of this problem (cloth component etc)

    2) enabling/disabling parts of code (binary search for the win!) until I tracked down what was producing invalid geometries. And flooded this part of code with asserts, so I started to get meaningful errors.

    Now it function is made mostly with asserts, but it allowed me to catch all bugs. And new ones will crash on assert rather than on meaningless AABB.

    Code (CSharp):
    1.     using UnityEngine.Assertions;
    2.  
    3. (...)
    4.  
    5.             Assert.IsTrue(distanceFromLeftRatio >= 0, "unexpected value " + distanceFromLeftRatio + " for distanceFromLeftRatio = " + distanceFromLeft + " / " + leaftRightDiff + " for " + position);
    6.             Assert.IsTrue(distanceFromLeftRatio <= 1, "unexpected value " + distanceFromLeftRatio + " for distanceFromLeftRatio = " + distanceFromLeft + " / " + leaftRightDiff + " for " + position);
    7.             Assert.IsTrue(distanceFromDownRatio >= 0, "unexpected value " + distanceFromDownRatio + " for distanceFromLeftRatio" + position);
    8.             Assert.IsTrue(distanceFromDownRatio <= 1, "unexpected value " + distanceFromDownRatio + " for distanceFromLeftRatio" + position);
    9.             Assert.IsTrue(leaftRightDiff > 0, "difference between left and right expected to be greater than 0, was " + leaftRightDiff + " for " + position);
    10.             Assert.IsTrue(upperLowerDiff > 0, "difference between up and down expected to be greater than 0, was " + upperLowerDiff + " for " + position);
    11.  
    12. (...)
    13.  
    14.             Assert.IsTrue(leftLower.x == rightLower.x, "unexpected topology: " + leftLower + " vs " + rightLower + " for source at " + position);
    15.             Assert.IsTrue(leftLower.z == rightLower.z, "unexpected topology: " + leftLower + " vs " + rightLower + " for source at " + position);
    16.             Assert.IsTrue(leftUpper.x == rightUpper.x, "unexpected topology: " + leftUpper + " vs " + rightUpper + " for source at " + position);
    17.             Assert.IsTrue(leftUpper.z == rightUpper.z, "unexpected topology: " + leftUpper + " vs " + rightUpper + " for source at " + position);
    18.             Assert.IsTrue(leftLower.x == leftUpper.x, "unexpected topology: " + leftLower + " vs " + rightLower + " for source at " + position);
    19.             Assert.IsTrue(leftLower.z == leftUpper.z, "unexpected topology: " + leftLower + " vs " + rightLower + " for source at " + position);
    20.             float h = TerrainIndexToHeight(leftLower);
    21.             //Debug.Log(position + " returned " + h + " in exact match produced " + h);
    22.             return h;
     
    laurentlavigne likes this.
  7. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    Object scale - that must be it, I'm sure that my code sets one object to 0
     
  8. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    or OnGUI scale

    upload_2020-4-29_16-14-35.png
     
  9. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    that's a new one... there were two particle systems, the shuriken ones, one was empty, nuked that one, all is fine and now the game runs at 50hz
     
  10. Zarkend

    Zarkend

    Joined:
    May 11, 2016
    Posts:
    28
    Hi, I found the problem (at least one causing it).
    I was having these errors
    upload_2020-9-28_22-55-47.png

    In my case it was caused for a skinned mesh renderer without valid bounds
    upload_2020-9-28_22-56-30.png

    How i found it

    In play mode (where i was facing this errors) I selected ALL the gameobjects in the scene and disabled them. At this point there was no errors. Then I enabled some of them till I find the one causing the problem.

    Hope it helps to someone!
     
    xjjon likes this.
  11. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    I wonder if this ^ can happen when scale is set very small
     
  12. alimardanov

    alimardanov

    Joined:
    May 7, 2020
    Posts:
    6
    This solved my problem. y scale was zero. I changed it to 1.
     
  13. Armend

    Armend

    Joined:
    Aug 8, 2015
    Posts:
    10
    I had this problem and what fixed it for me was simply selecting the size of the Gamewindow in the Game Tab. Changed it from "Free Aspect" to "1920x1080 Landscape".
     
    bobadi likes this.
  14. Lord_Legion

    Lord_Legion

    Joined:
    Dec 30, 2020
    Posts:
    7
    I had the same problem and it appeared after I implemented a pause in the game. During the pause, I was holding down the button to go forward and that’s why the error occurred. Namely, the error was in the Cs Homebrew IK plugin
     
    Last edited: Feb 2, 2024
  15. thenoux

    thenoux

    Joined:
    Aug 23, 2022
    Posts:
    3
    For me, the error occurred when in a script (due to a typing error) a division by zero (0/0) was generated. I hope it helps you find your solution, greetings.