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 jpthek9 · Jan 06, 2015 at 07:10 PM · rotationquaternionlerp

Lerping Quaternions Results in NaN's

 void Start(){
 Quaternion MyRotation = Quaternion.Euler (Vector3.zero);
 Quaternion LastRotation = MyRotation;
 Quaternion tempRot =  Quaternion.Lerp(LastRotation, MyRotation, 1);
 }

The code above turns up with this debug log:

'CompareApproximately (aScalar, 0.0F) UnityEngine.Quaternion:Lerp(Quaternion, Quaternion, Single)'.

Is there any way to prevent this from happening? My guess is checking some kind of null reference exception for quaternions but I'm not sure what that is. Note: This is a simplified version of my script. Solving the problem in this code will solve the problem in my full code.

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 BenZed · Jan 06, 2015 at 07:34 PM 0
Share

There's nothing wrong with this code, save for fact that it's redundant. The result of tempRot will be the same as transform.rotation, so lerping it by any factor would always result in the same factor.

I realize that this is just for the sake of example, so it's probably a moot point.

In any case, the problem has to be somewhere else.

avatar image jpthek9 · Jan 06, 2015 at 07:47 PM 0
Share

Oh, I guess you're right! I wish there was a debug log for when $$anonymous$$yRotation turned up invalid in my code.

So I combed through my code and printed $$anonymous$$yRotation. I'll change the code above to properly replicate the problem.

Okay, I'm honestly at 100% loss for what to do. I can't reproduce this bug and my script's a bit long. If you don't $$anonymous$$d, would you comb through it?

1 Reply

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

Answer by jpthek9 · Jan 06, 2015 at 08:04 PM

This is a facepalm moment. I had a return; in my Start method that stopped the rest of the start if the unit was not mine. MyRotation was never assigned.

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

26 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

Related Questions

How can I smooth the rotation using quaternion and raycast? 1 Answer

Smoothly Rotate 2D sprite 90 degrees on click 2 Answers

Smoothing the characters rotation with Lerp 2 Answers

better way to rotate instead Coroutine 1 Answer

Use Lerp to rotate object 2 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