• 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 /
This question was closed Aug 21, 2016 at 11:01 PM by stephen_george98 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by stephen_george98 · Aug 21, 2016 at 09:32 PM · rotationvector3quaternionslerplookrotation

LookRotation Vector3 is Zero, Yet Slerp Still Rotates?

 Vector3 vector3 = new Vector3 (0.0f, 0.0f, 0.0f);
 
 Quaternion qTo = Quaternion.LookRotation (vector3);    
 
 transform.rotation = Quaternion.Slerp (transform.rotation, qTo, Time.deltaTime * turnspeed);

(See code above). If my LookRotation vector3 is zero in every axis, why does my this Slerp function I have here still rotate my character 90 degrees? I am just curious and honestly quite baffled. I can send screenshots if you need a visual representation of this.

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

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by ScaniX · Aug 21, 2016 at 09:49 PM

See https://docs.unity3d.com/ScriptReference/Quaternion.LookRotation.html

You actually pass a forward vector into the method. Instead of crashing with your invalid vector, it seems to fall back to some default (probably Vector3(0, 0, 1)) and return that look direction instead. And that is the rotation you get.

If your character transform has a forward vector like Vector3(1, 0, 0) that would result in a rotation of 90° around the world y-axis.

Don't you get an error in the console? The documentation says: "Logs an error if the forward direction is zero."

Comment
Add comment · Show 1 · 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 stephen_george98 · Aug 21, 2016 at 10:44 PM 0
Share

Yes I do get a notification that says "Look rotation viewing vector is zero" in the console. Thank you for your response :) @ScaniX

avatar image
0

Answer by LK84 · Aug 21, 2016 at 09:47 PM

Have a look at the definition of Quaternion.Slerp: "Spherically interpolates between a and b by t. The parameter t is clamped to the range [0, 1]."

So as long as your current transform.rotation is not equal to zero rotation (Im honestly not sure if you get Quaternion.identity from LookRotation(Vector3.zero)), Slerp will return a value between these two rotations.

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

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

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

Related Questions

Slerp to make the right/left side face another object 2 Answers

What am I doing wrong with these rotations? 0 Answers

Turret rotation on one axis problems 2 Answers

Quaternion.Slerp with Quaternion.LookRotation causes unexpected results 1 Answer

Quaternion.LookRotation and Vector3.SmoothDamp Problems 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges