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 jvt619 · Dec 09, 2013 at 12:57 PM · camerarotationmousevectorslerp

Rotation always changing values!

 Vector3 rot = transform.localEulerAngles;
        if(Input.GetKey(KeyCode.P))
        {
          rot.y = 160.0f;
  
          mouseLook.enabled = false;
          theCamera.localRotation = Quaternion.Slerp(theCamera.localRotation, Quaternion.Euler(rot), Time.deltaTime * 10);
        }
  
        else
        {
          mouseLook.enabled = true;
          theCamera.localRotation = Quaternion.Slerp(theCamera.localRotation, Quaternion.identity, Time.deltaTime * 10);
        }


How do I fix the camera rotation so that it will not change all the time if localRotation.y will reach to zero after I released the "P" button

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 CHPedersen · Dec 09, 2013 at 01:08 PM 0
Share

It's because you're animating wrong; you're using 10 * Time.deltaTime, which is almost constant and only varies slightly each frame, ins$$anonymous$$d of allowing the interpolation parameter to depend linearly on time. Use Time.time ins$$anonymous$$d and set some initial startTime, then count up each frame from there.

avatar image jvt619 · Dec 10, 2013 at 01:58 AM 0
Share

can you give me an example on how to do it

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by The Kracken · Dec 10, 2013 at 02:25 AM

 float timeframe = 0;
 timeframe += Time.deltaTime/10.0f; //lets rotate over 10 seconds
 theCamera.localRotation = Quaternion.Slerp(theCamera.localRotation, Quaternion.Euler(rot), timeframe);

timeframe needs to go from 0-1 to complete the slerp. when you do Time.deltaTime*10, its only staying at around the value of dt*10 and not going from 0-1;

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

18 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

Related Questions

Need help on the 3ds max style camera control 0 Answers

Mouse.position from center of player 1 Answer

Smooth camera rotation on mobile and pc when GetMouseButton()? 0 Answers

Limiting the rotation to 180 degrees 0 Answers

Gameobject Rotation Calculation 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