Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 smoggach · Oct 10, 2014 at 07:07 PM · quaterniondebug.log

preventing errors by calling Debug.Log on a property

Hi there. In my project I'm animating the position and field of view of a perspective camera. I also have a script that modifies an object's rotation in a LateUpdate.

 Quaternion To Matrix conversion failed because input Quaternion is invalid {-0.073833, 0.885253, 0.000000, 0.777146} l=1.393081


The line of code that causes this is

 transform.localRotation = originalRotation


This is fine, I know why it's giving me this error. Everything behaves as I expect as anyways. The interesting thing is that I can get this error message to go away just by calling this line of code first:

 Debug.Log(transform.localRotation);


What could Debug.Log possibly be doing that fixes my quaternion?

Comment
Add comment · Show 2
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 ThePunisher · Oct 10, 2014 at 08:52 PM 0
Share

I can't see why it would "fix" the error. It might just be that Unity is not spam$$anonymous$$g your error because you are actively logging and it doesn't want to drown your debugs with it. I don't know though, that's kinda weird.

Are you 100% sure that your transform.localRotation is still getting modified after putting the debug.log statement in first?

avatar image smoggach · Oct 11, 2014 at 03:12 PM 0
Share

Yes. The code properly sets the rotation and there's really no difference in behaviour. It's also not a spammy error, it's more of an intermittent error maybe once every 5 - 10 seconds.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by denisb · Oct 11, 2014 at 03:56 AM

it may be a race condition, when you dont call debug.log your originalRotation may be undefined, and if you do debug.log it takes some time and the originalRotation has been set meanwhile.

Comment
Add comment · Show 3 · 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 smoggach · Oct 11, 2014 at 03:16 PM 0
Share

You may be right. However originalRotation is only set once in Awake(). I think the reference in question here is the actual transform.rotation. I figured that by doing this code in LateUpdate I would avoid having conflicts with other things modifying the transform. Perhaps I have some other LateUpdate doing things to it? I'll look into it.

avatar image ThePunisher · Oct 13, 2014 at 05:03 PM 0
Share

That's a good idea @denisb. I totally didn't about it but I have seen race conditions become rarer or simply go away in some cases just by adding process intensive code to the code base.

The only thing I would say though is that LateUpdate is always going to happen after Update so I don't think that would cause problems. I would start by process of eli$$anonymous$$ation just removing the Debug.log so that the error comes up again and then removing transform modifications one by one until I can make sense of it.

avatar image smoggach · Oct 14, 2014 at 02:15 PM 0
Share

I found a bunch of other things doing stuff in LateUpdate. I'm willing to guess here the race condition is because one is trying to change the position and one is trying to change the rotation. However since it's a perspective camera, changing the position in turn changes the rotation and this is what's fighting. I'll use coroutines to space them out over a frame or so.

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

30 People are following this question.

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

Related Questions

how do I compare Quaternions? 6 Answers

Quaternion and 360 degree rotations 1 Answer

Rotate GameObject on click 1 Answer

Changing the speed of a rotating object 2 Answers

Quaternion rotation issue 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