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
1
Question by Rynold · Jan 25, 2014 at 01:41 AM · deltatimerotatetowards

Why when I use Time.deltaTime, it slows down my rotation

I'm trying to rotate a 2D sprite I have smoothly, I get what angle it should be and store it in temp then I use Quaternion.RotateTowards() to rotate towards what I want its new angle to be. When I make the last value just a normal float it rotates perfectly, however when I multiply it by Time.deltaTime it makes it move really slow. How can I fix this so I can still use Time.deltaTime for its benefits?

 if (transform.rotation != temp)
 {
     transform.rotation = Quaternion.RotateTowards(transform.rotation, temp, rotationSpeed * Time.deltaTime);
 }

temp is just what I want its new rotation to be.

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 getyour411 · Jan 25, 2014 at 01:46 AM 0
Share

Try increasing rotationSpeed?

avatar image Rynold · Jan 25, 2014 at 01:52 AM 0
Share

ya that worked, I just didn't think it would because I would use 2 for tranlating other objects and it moved at a pretty fine pass, but apparantly 2 when where dealing with rotating is much much slower haha, So i had to put it up to like 75. Thanks :D

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by OP_toss · Jan 25, 2014 at 01:54 AM

First off, let me just say your code is fine. You need to increase your rotation speed, as it is now in terms of degreesPerSecond, not degreesPerUpdate.

Now in case you don't quite understand what Time.deltaTime is used for, allow me to explain:

Any compounding change in a value every update needs to take Time.deltaTime into account. This allows for an object going 5 units per UPDATE to now go 5 units per SECOND. The reason this is necessary is because Updates can potentially lag, causing the time between update 1 and 2 to not equal the time between update 2 and 3. This makes our object move faster on faster computers. This we do not want. Thus, we convert to SECONDS, which alleviates this issue.

Now it appears in your issue that you want your object to Rotate towards a particular vector, with a max speed of rotationSpeed. This looks good, but since you're applying this every update (I assume), you need to take into account Time.deltaTime, as you have done.

If you don't want to change your variable to a larger number, for whatever reason, you can simply multiply your value by 0.02 (or some such number) once, then use the decreased number in the above calculation. This basically is converting to what your Time.deltaTime would be at 50fps.

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

19 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

Related Questions

RotateTowards with deltaTime Causes Spinning! 0 Answers

Time.Delta time inconsistent 0 Answers

Time.deltaTime not set to 0 if Time.timeScale set to 0 too early! 4 Answers

How to move object when the frame rate is extreme low 1 Answer

Smooth rotation... 1 Answer


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