Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by looak · Jun 20, 2011 at 11:53 AM · erroronguinan

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 );
         }
     }
 }
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Joshua · Jun 20, 2011 at 01:41 PM 0
Share

Are you directly setting the sceneCamera's transform? Do you have this error on one machine with every project or with one project on every machine?

avatar image looak · Jun 20, 2011 at 04:07 PM 0
Share

$$anonymous$$ight not even be that script that crashes itall just that it seems like it is this one since when i remove it never happens again..

avatar image Bunny83 · Jun 20, 2011 at 04:55 PM 0
Share

First of all, thanks for moving the code to the question. I think you are the first one that actually changed the question :D.

As i said i don't see anything in those scripts that could cause that error. It seems that there's something messed up in the scene file. What if you "Revert Factory Settings" and then save your scene and project.

If that doesn't help you could try to copy the used prefabs and those scripts either into a new scene or a completely new project. If the error persists you should pack up an example project and file a bug report.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jun 20, 2011 at 01:48 PM

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?

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Jun 20, 2011 at 01:54 PM 0
Share

Do you use Resources.FindObjectsOfTypeAll anywhere in your scripts? Because you have to be careful with that (like the docs already said). It returns ALL objects of that type, even the internal invisible GameObject that represents the SceneCamera.

avatar image looak · Jun 20, 2011 at 01:55 PM 0
Share

I ain't touching the sceneCamera in any editorscripts anywhere.. and the only thing i do with Quaternions is that i instansiate a gameobject with Quaternion.identity.

avatar image looak · Jun 20, 2011 at 01:57 PM 0
Share

Never use that method.. "FindOjbectsOfTypeAll"

avatar image ina · Nov 02, 2011 at 08:00 AM 0
Share

How do you check for quaternion values that are valid? How to check if not NaN o.O

avatar image Bunny83 · Nov 04, 2011 at 12:31 PM 0
Share

@ina: That's not really the question here since it's far more important to get behind the piece of code that makes the members of the quaternion "NotANumber". To check a float value against NAN see this question

avatar image
0

Answer by looak · Jun 21, 2011 at 07:33 AM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

2 Scripting Errors I need help fixing!! 3 Answers

Quaternion To Matrix conversion failed 1 Answer

Problem creating GUI.Window, Help please! 1 Answer

blackberry error (Author Id, etc...), no script added ye... 1 Answer

ArgumentException: Getting control 0's position in a group with only 0 controls when doing Repaint 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges