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 /
  • Help Room /
avatar image
0
Question by mdefasqu · Mar 22, 2016 at 03:33 AM · quaternionlerp

Error : "!CompareApproximately (aScalar, 0.0F)" with Quaternion.Lerp

I Everyone, i'm stuck with an error since a wile now and i hope one of you have a solution for me. Here is my code :

    private void lookTarget(Vector3 pos){
         Quaternion newRotation = Quaternion.LookRotation(transform.position - pos, Vector3.down);
         newRotation.x = Quaternion.identity.x;
         newRotation.z = Quaternion.identity.z;

         transform.rotation = Quaternion.Lerp(transform.rotation, newRotation, Time.deltaTime * 10);
     }

And it give me sometimes this error :

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

I Try to found an answer on internet but without succes. If someone have the solution it will help me a lot.

Thank's everyone.

Comment
Add comment
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

5 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by helgewl · Oct 26, 2016 at 02:28 PM

You probably have a (0, 0, 0, 0) Quaternion in either end of the lerp.

PS: I know this is an old question, but it was #2 in my Google search results.

Comment
Add comment · Show 2 · 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 BenLiyanage · Oct 18, 2020 at 09:11 PM 0
Share

What's this fix for this? (aka why can't you lerp to (0,0,0)?)

avatar image unity_PNVpFX7xnCpieQ · Nov 08, 2020 at 02:47 AM 0
Share

a Quaternion is undefined when it is (0,0,0,0).
I was getting this when my app was starting cause I didn't initialize it with Quaternion.identity or some real value. Once set, then the error was going away. If you don't want to initialize your Quaternion, you could do something like

 private bool IsQuaternionInvalid(Quaternion q) {
     bool check = q.x == 0f;
     check &= q.y == 0;
     check &= q.z == 0;
     check &= q.w == 0;
 
     return check;
 }
 


avatar image
0

Answer by mdefasqu · Mar 23, 2016 at 04:19 AM

Nobody has an idea ?

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
avatar image
0

Answer by kjuanlu · Mar 15, 2018 at 04:13 PM

The error happens when you use Time.deltatime as part of the third parameter. Try to change transform.rotation = Quaternion.Lerp(transform.rotation, newRotation, Time.deltaTime * 10); by transform.rotation = Quaternion.Lerp(transform.rotation, newRotation, 0.01f * 10);

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
avatar image
0

Answer by Nishat11 · Sep 25, 2018 at 09:55 PM

Try this, as Quaternion.Lerp clamps between 0 & 1.

 float temp_speed = Time.deltaTime * speed;
 if(gameObject.transform.rotation != null && temp_speed < 1)
     transform.rotation = Quaternion.Lerp(gameObject.transform.rotation, target_rotation, temp_speed);


for more understanding link text

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
avatar image
0

Answer by qiaokeli_sucai · Aug 28, 2019 at 03:59 AM

The error happens when the third parameter is larger than 1 . Try to change transform.rotation = Quaternion.Lerp(transform.rotation, newRotation, Time.deltaTime * 10); by

 float t =  Mathf.Clamp(Time.deltaTime * 10, 0f, 0.99f);
 transform.rotation = Quaternion.Lerp(transform.rotation, newRotation, t);

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

56 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 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

Creating points for robot (End Effector) to go through them 0 Answers

Smooth Rotation Quaternion Lerp? 1 Answer

Quaternion lerp slowing down movement? 1 Answer

How to smoothly rotate gameobject 20 degrees on key press? 0 Answers

Rotate on Transform.localeulerAngels smoothly 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