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 fede9948 · Dec 18, 2016 at 07:46 AM · charactercontrollerrotateerror messagemouselook

Assertion failed on expression: 'IsNormalized (ray.GetDirection ())'

So, I was programming a very simple mouse look script. The vertical rotation works fine (I only rotate the camera there), but if I try to rotate my player in horizontal direction, I get this error message:
Assertion failed on expression: 'IsNormalized (ray.GetDirection ())'
The mouse look itself works fine, but I get 60 of those error messages per second, which certainly isn't a good thing.
This is my code:
CharacterController playerMotor; Camera cam;

 void Start () {
         playerMotor = GameObject.Find("Player").GetComponent<CharacterController>();
         cam = Camera.main;
     }
 
 void MouseLook ()
     {
         //this function is called in FixedUpdate ()
         Vector3 horizontalRotation;
         Vector3 verticalRotation;
         horizontalRotation = new Vector3(0, Input.GetAxis("Mouse X"), 0);
         verticalRotation = new Vector3(Input.GetAxis("Mouse Y"), 0, 0);
         playerMotor.transform.Rotate(horizontalRotation);
         cam.transform.Rotate(-verticalRotation);
     }

I had more or less the same script in an older version of Unity. Since the last update I get that error message though. Does anyone know why this could happen?
I'm using Unity 5.5.0f3 btw.

Comment
Add comment · Show 6
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 ElijahShadbolt · Dec 18, 2016 at 08:53 AM 1
Share

I don't know what's going wrong. Your script is working fine for me, also on Unity 5.5.0f3

What is the whole error message? Which line numbers in which scripts? Are you sure it is from this function, and not somewhere else?

avatar image fede9948 ElijahShadbolt · Dec 19, 2016 at 03:53 PM 0
Share

I tested it out, and without the line where I rotate the player (not just the camera) player$$anonymous$$otor.transform.Rotate(horizontalRotation);, I don't get the error message.
The error message is exactly as mentioned in the title, but oddly there isn't any information about in which script/line the error occurs.

avatar image Bunny83 · Dec 19, 2016 at 04:59 PM 1
Share

This is most likely related to some other component in your game. C# doesn't really have "assertions" by default. That's why the error has to come from a built-in component. Somewhere either a script or a built-in component builds a Ray (probably from your camera's orientation). For some reason the ray direction vector isn't normalized. That's what the assertion checks on the C++ side.

We can only guess what might be the reason for this, but possible causes are:

  • A deep object hierarchy or objects with non-uniform scaling and child object rotation. The last thing will cause shearing in the transformation matrix and might result in some strange transfomations.

  • A scale of 0 or at least a very extreme value (small or large) could theoretically cause this as well.

Do you use the new UI system? It also requires a ray for hit detection.

The problem isn't in the script you posted, even if that line of code causes it.

avatar image fede9948 Bunny83 · Dec 19, 2016 at 09:22 PM 1
Share

Ok thanks for the detailed information. I didn't have much in that project anyways, so I did a fresh restart (creating a new project) and rewrote the same piece of code, this time no errors. Could be that some file was corrupted because I imported the other project from an older version of Unity.
Thanks again for the quick reply of all you guys,
Happy program$$anonymous$$g and kind regards :)

avatar image Acreates · Mar 12, 2017 at 06:10 AM 0
Share

Ditto error here...just started happening, is there a fix?

avatar image fede9948 Acreates · Mar 13, 2017 at 04:05 PM 0
Share

Okay, so I haven't had this issue now since I posted the last comment on this questions. But I solved it by starting anew.

  1. Create a new Unity project.

  2. Copy and paste all the assets you need

  3. If it still doesn't work, try copying the script text ins$$anonymous$$d of the whole script file itself

  4. Enjoy bug-free project

I believe this issue occurs when running an older-version-project in an updated version of Unity. Some metadata might be corrupted or wrong then.
Hope this works for you

0 Replies

· Add your reply
  • Sort: 

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Camera rotation around player while following. 6 Answers

Rotating Object with Mouse Axis is very choppy 1 Answer

player isn't rotating along y-axis 0 Answers

Character making an unneeded rotation when first rotating camera around before moving 1 Answer

Making a Model move with the Mouse 1 Answer


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