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 voncarp · Sep 21, 2013 at 11:56 PM · quaternioncamera rotate

Rotating camera with Quaternion

I am trying to rotate my camera smoothly from one direction to another.

I have been setting my camera rotation with

 Cam.newCamRotation = Quaternion.Euler (2, 152,349);



So I am trying to rotate from one rotation to another smoothly. So I made an effort with this adding it to the LateUpdate.

     if (rotatesmooth){        
     newCamRotation = Quaternion.Lerp (Quaternion.Euler(0, 0,180),Quaternion.Euler(2, 152,349), 3f * Time.deltaTime );
     }

It doesn't seem to do anything except jitter a little bit. The rest of my code is pretty extensive and the mistake may be somewhere else, but I think the issue is the part I am asking about. Anyone have any suggestions?

thanks

Comment
Add comment · Show 3
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 Fattie · Sep 22, 2013 at 06:57 AM 0
Share

Generally simply use .Rotate or maybe .LookAt, There is little reason to ever touch quaternions.

avatar image robertbu · Sep 22, 2013 at 10:42 AM 0
Share

@Fattie - I know your stance on Quaternions, but smooth rotation over time is much more cumbersome without them.

avatar image Fattie · Sep 22, 2013 at 03:04 PM 0
Share

i agree, I mean purely for beginners

2 Replies

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

Answer by robertbu · Sep 22, 2013 at 12:56 AM

What you have here won't work (Slerp() or Lerp()). There are a couple of different ways to solve your problem depending on what you want.

1) You can implement a timer. When you fix both the start and end of the rotation, you need the values for the third parameter of Slerp to go from 0 to 1. Values outside this range do nothing. Your current code uses a small, but fluctuating value for the third parameter.

 newCamRotation = Quaternion.Slerp (Quaternion.Euler(0, 0,180),Quaternion.Euler(2, 152,349), fraction );

2) Use the current rotation as the first parameter. This produces an eased movement:

 newCamRotation = Quaternion.Slerp (newCamRotation,Quaternion.Euler(2, 152,349), speed * Time.deltaTime);

3) Use the current rotation and change to using Quaternion.RotateTowards(). This produces a movement at a fixed speed.

 newCamRotation = Quaternion.RotateTowards (newCamRotation,Quaternion.Euler(2, 152,349), speed * Time.deltaTime);
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 voncarp · Sep 22, 2013 at 01:07 AM 0
Share

Thanks for the response. What I have seems the same as your solution number two, but it doesn't seem to have an effect.

avatar image robertbu · Sep 22, 2013 at 01:11 AM 0
Share

The code you have above is not #2. Please post your code and I'll take a look. Note I need to see how newCamRotation is set and handled.

avatar image voncarp · Sep 22, 2013 at 01:44 AM 0
Share

Your right. I fixed it with your number two solution. Thank you very much.

avatar image
0

Answer by DaveA · Sep 22, 2013 at 12:06 AM

Try Slerp

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 voncarp · Sep 22, 2013 at 12:11 AM 0
Share

That didn't seem to work. Is it likely then, my mistake is somewhere else in the code?

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

17 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

Related Questions

Save last rotation or the camera and apply it after end of event. 0 Answers

Quaternion.LookRotation does not seem to work for android 0 Answers

how do you sway the camera based on sharp turns 0 Answers

rotation along the y-axis with damping not working! 0 Answers

FPS camera is repositioning on both the X and Y axis, I only want the camera to slightly tilt (Z axis)...TIA! 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