Search Unity

Rotation is No Longer Valid and Quaternion to Matrix Conversion Failed

Discussion in '2D' started by Wuzseen, Nov 14, 2013.

  1. Wuzseen

    Wuzseen

    Joined:
    Apr 19, 2011
    Posts:
    20
    I've been transitioning my project to utilize the 2D features and have been getting these errors:

    I have an idea of what it's telling me, but i'm not exactly sure how I fix it! Any ideas? The game object that is throwing it has no code that is relevant to its rotation.

    I removed a bunch of code and tried to nail down where it was happening and I was able to exclude a couple possibilities. Collisions seem to not be the apparent cause. Objects that throw the issue are children of other objects. The object they are child to is rotating.
     
    Last edited: Nov 14, 2013
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,445
    Are you ever trying to manipulate the rotation's members independently? Like "rotation.y = 0"? This is a big no-no with quaternions, as the x, y, z, w members are not independent, like they are with euler angles. Use the methods that operate on a rotation instead: LookRotation(), RotateTowards(), etc.

    Mathematically, a quaternion needs to be a normalized 4D vector; that is, x[SUP]2[/SUP]+y[SUP]2[/SUP]+z[SUP]2[/SUP]+w[SUP]2[/SUP]=1.0. It looks like the error message is telling you that the 4D vector's magnitude is 1.000011, sufficiently wrong to make matrix conversion horribly inaccurate or impossible.

    (I looked back at the quaternion docs. They include this handy warning: Don't modify this directly unless you know quaternions inside out.)
     
    Last edited: Nov 14, 2013
  3. Wuzseen

    Wuzseen

    Joined:
    Apr 19, 2011
    Posts:
    20
    I'll take another pass through the project, but I don't believe I manipulate Quaternions directly anywhere but I don't remember everything in the code either. Thanks for the help!
     
  4. Wuzseen

    Wuzseen

    Joined:
    Apr 19, 2011
    Posts:
    20
    I don't manipulate quaternions or rotation anywhere in my code save for this spot--this is the code that moves the parent object that the objects throwing errors are:
    Code (csharp):
    1.     protected void Rotate() {
    2.         if(catnip > 0) {
    3.             catnip -= Time.deltaTime;
    4.             theSpawner.spawnTime = .5f;
    5.         }
    6.         else {
    7.             catnip = 0;
    8.             theSpawner.spawnTime = 1f;
    9.         }
    10.         float catNipMod = catnip > 0 ? catNipForce : 1;
    11.         float rotateSpeed = flip * (catNipMod) * .1f * (collected.Count + 1);
    12.         if(rotateSpeed > 1f * catNipMod)
    13.             rotateSpeed = 1f * catNipMod;
    14.         transform.Rotate(0,0,rotateSpeed);
    15.     }
    Basically the code just checks if the player has something which modifies the rotation speed of the object. (This is called in update). This isn't new code in the project--it's been around basically since day one.

    Did some more fiddling:

    Whenever the parent object has 5 or more children it does this.
     
    Last edited: Nov 14, 2013
  5. k3pp

    k3pp

    Joined:
    May 2, 2013
    Posts:
    23
    I´m having the same error... I´m using a skinned mesh with 2d physics joints in the bones... without any script, just rotating the object in the scene, unity pops thousand identical errors:

    transform.rotation of '3' is no longer valid, due to a bad input value. Input rotation is 0.000000, 0.000000, 0.165046, -0.986286.

    maybe it´s a unity internal 2d error?
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Parent a "new" particle system set to simulation space "Local" to a Mixamo bone and you get the same ridiculous error.
     
    Last edited: Dec 16, 2014