SceneCamera NAN persisting problem

Hey,

In our porject now we keep getting this error

transform.rotation assign attempt for ‘SceneCamera’ is not valid. Input rotation is { NaN, NaN, NaN, NaN }.
UnityEditor.DockArea:OnGUI()

I know how to get rid of it, by either cloesing and reopning the sceneview or going to window->Layouts->Revert Factory Settings… Though it comes back everytime we play our scene. Does anyone have any clue to what it is that creates this error? Is there anything that is known to generate this error?

Kind Regards
Alex

Edit:

I have figured out which script that is causing the problems… If I remove it from the scene everything works fine and I don’t get the SceneCamera error. But the script is so basic that I can’t see how it would generate this error…

using UnityEngine;
using System.Collections;

public class CloudScriptHandler : MonoBehaviour {

    public GameObject[] listOfClouds;
    public Vector2 spawnTimeRandomSeeds;
    public Vector2 cloudSpeedRandomSeeds;

    public Vector3 positionMax;

    public Vector3 positionMin;

    float spawnTimer;
    float timeToSpawn;

    // Use this for initialization
    void Start () 
    {
        timeToSpawn = Random.Range(spawnTimeRandomSeeds.x,spawnTimeRandomSeeds.y);

    }

    // Update is called once per frame
    void Update () 
    {
        spawnTimer += Time.deltaTime;

        if( spawnTimer >= timeToSpawn )
        {
            CreateNewCloud();
            timeToSpawn = Random.Range(spawnTimeRandomSeeds.x,spawnTimeRandomSeeds.y);
            spawnTimer = 0.0f;
        }

    }

    void CreateNewCloud()
    {
        int maxRand = listOfClouds.Length - 1;
        int randCloud = Random.Range( 0,  maxRand );
        GameObject clone;
        clone = Instantiate( listOfClouds[randCloud], CalculatePosition(), Quaternion.identity) as GameObject;
        clone.transform.parent = gameObject.transform;

        clone.GetComponent<CloudScript>().cloudSpeed = Random.Range(cloudSpeedRandomSeeds.x, cloudSpeedRandomSeeds.y );
    }

    Vector3 CalculatePosition()
    {
        Vector3 newPosition = new Vector3();

        newPosition.x = Random.Range( positionMin.x, positionMax.x );
        newPosition.y = Random.Range( positionMin.y, positionMax.y );
        newPosition.z = Random.Range( positionMin.z, positionMin.z );

        return newPosition; 
    }
}

using UnityEngine;
using System.Collections;

public class CloudScript : MonoBehaviour {

    public float cloudSpeed = 1.0f;

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update ()
    {

        Vector3 newPosition = gameObject.transform.position;
        newPosition.x -= Time.deltaTime * cloudSpeed;
        gameObject.transform.position = newPosition;

        if( newPosition.x <= -200 )
        {
            Destroy( this.gameObject );
        }
    }
}

It sounds like you’ve messed up the quaternion values. Rotations in Unity are stored as Quaternions(wikipedia).

If you set x,y,z,w to illegal values that error could happen. Also if you set the eulerAngles to values outside of a full circle it will throw that error as well.

Don’t set one of the members of a quaternion yourself. The 4 values (x,y,z,w) represent a normalized complex 4-dimensional equation. Use either transform.Rotate or create an absolute rotation with Quaternion.Euler.

edit

Just read that the error states that the SceneCamera is messed up… Do you use any editorscripts that access the scene camera?

So I’ve figured out what it was that caused the issue, but it still amazes me the results we get from this simple and very usual misstake. We had forgot to attach the CloudScript to the GameObjects that we were trying to instantiate. Doesn’t make any sens to me why that would screw the SceneCamera but it did. Though the bug is gone now and we can continue developing our game with out this distraction.

Might not be the solution for others with the same issue but it was what caused it for us.

Regards,

Alex