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 Bitpocketer · Nov 07, 2014 at 12:24 PM · rotationfpsrotate

Questions about frame rate

As update is called every frame,so if my frame rate is 70fps, does that mean update is called 70 times per second?and if anything happening inside update function,does that mean it also happens 70 times per second?

I'm confused with the following statements

 void Update()
 {
     transform.Rotate(new Vector3(0,20,0));
 } 

it rotates my GameObject 20 units along y axis every frame.and if the frame rate is 70 fps,does that mean gameobject gets rotated 70 times 20 units in one second? Lets say i want to rotate the Gameobject along y axis 20 units per second, so it's done by the following statements

 void Update()
 {
     transform.Rotate(new Vector3(0,20*Time.deltaTime,0));
 }

this also gets called every frame, but what exactly multiplying the value 20 with Time.deltatime does to make the gameObject rotate 20 units per second? It's written in the documentation that Time.deltaTime returns the elapsed time since last call to the update method. What's happening here i can't seem to get insight into that, kindly make me understand.

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

· Add your reply
  • Sort: 
avatar image
1

Answer by Baste · Nov 07, 2014 at 12:35 PM

You're pretty much spot on - Update is called once every frame. More correctly: your fps is pretty much how often the game manages to call Update (and all of the other methods) on all the stuff in your game.

So 60fps means that your game's managing to call Update 60 times a second.

Now, if you want to rotate something 20 degrees each second, and you're running at 60 fps, that means that on every frame you want to rotate the same object 20/60 = 1/3 degree per frame. On the other hand, if the exact same game's running on just 30 fps, you'll want 20/30 = 2/3 degrees per frame.

This is where deltaTime comes in. Time.deltaTime is the time since the last frame. Thus, if you're running on 60 fps, Time.deltaTime will be 1/60. If you're running at 30 fps, Time.deltaTime is 1/30.

Notice here that that's exactly what you need to get the correct number of degrees per frame to rotate your object. If you do Time.deltaTime * 20, you get:

on 60 fps: 1/60 * 20 = 20/60 = 1/3

on 30 fps: 1/30 * 20 = 20/30 = 2/3

So, what multiplying with Time.deltaTime is doing for you is making sure that your object rotates at 20 degrees per second, no matter what the frame rate is. Hope that makes it clear!

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 robertbu · Nov 07, 2014 at 12:37 PM

Any frame rate associated with Update() will be an average or an approximation, and yes if the stats window is showing a frame rate of 70 fps, then Update() is getting called approximately 70 times per second. Things like garbage collection and loads you place on the app will make the number vary frame to frame and on average. And yes, that mean in your second example that your object is getting rotated 70 * 20 degrees every second.

As for your last example, sometimes the easiest way to figure things out by doing them by hand. So to make things easy, lets assume the frame rate is 50 fps. That means Update() is called approximately every 1/50 (0.02) seconds. And so Time.deltaTime times 20 is 0.02 times 20 is .4 degrees per frame. And if we do a .4 degree rotation 50 times, we get 20 degrees of rotation.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Heya again guys how about rotation and score board 0 Answers

Need help with rotation script. 1 Answer

Rotating wrong 0 Answers

Object won't rotate z axis on second click? 2 Answers

How do I attach a character to a fps controller / make him rotate? 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