Oh, this one. Unity complains that you have invalid geometries.
Random Invalid AABB inAABB error – Questions & Answers – Unity Discussions 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”).
Reddit – Dive into anything 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:
-
googling for checking whatever you are using common sources of this problem (cloth component etc)
-
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.
using UnityEngine.Assertions; (…) Assert.IsTrue(distanceFromLeftRatio >= 0, “unexpected value ” + distanceFromLeftRatio + ” for distanceFromLeftRatio = ” + distanceFromLeft + ” / ” + leaftRightDiff + ” for ” + position); Assert.IsTrue(distanceFromLeftRatio <= 1, “unexpected value ” + distanceFromLeftRatio + ” for distanceFromLeftRatio = ” + distanceFromLeft + ” / ” + leaftRightDiff + ” for ” + position); Assert.IsTrue(distanceFromDownRatio >= 0, “unexpected value ” + distanceFromDownRatio + ” for distanceFromLeftRatio” + position); Assert.IsTrue(distanceFromDownRatio <= 1, “unexpected value ” + distanceFromDownRatio + ” for distanceFromLeftRatio” + position); Assert.IsTrue(leaftRightDiff > 0, “difference between left and right expected to be greater than 0, was ” + leaftRightDiff + ” for ” + position); Assert.IsTrue(upperLowerDiff > 0, “difference between up and down expected to be greater than 0, was ” + upperLowerDiff + ” for ” + position); (…) Assert.IsTrue(leftLower.x == rightLower.x, “unexpected topology: ” + leftLower + ” vs ” + rightLower + ” for source at ” + position); Assert.IsTrue(leftLower.z == rightLower.z, “unexpected topology: ” + leftLower + ” vs ” + rightLower + ” for source at ” + position); Assert.IsTrue(leftUpper.x == rightUpper.x, “unexpected topology: ” + leftUpper + ” vs ” + rightUpper + ” for source at ” + position); Assert.IsTrue(leftUpper.z == rightUpper.z, “unexpected topology: ” + leftUpper + ” vs ” + rightUpper + ” for source at ” + position); Assert.IsTrue(leftLower.x == leftUpper.x, “unexpected topology: ” + leftLower + ” vs ” + rightLower + ” for source at ” + position); Assert.IsTrue(leftLower.z == leftUpper.z, “unexpected topology: ” + leftLower + ” vs ” + rightLower + ” for source at ” + position); float h = TerrainIndexToHeight(leftLower); //Debug.Log(position + ” returned ” + h + ” in exact match produced ” + h); return h;
