Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Play_Kim · Jan 19, 2017 at 04:34 PM · scripting problemtutorialspace shooterdeltatimesmoothing

[tutorial - Space Shooter] about smoothing in EvasiveManeuver.cs

 void FixedUpdate() {
     float newManeuver = Mathf.MoveTowards(rb.velocity.x, targetManeuver, Time.deltaTime * smoothing);
     rb.velocity = new Vector3(newManeuver, 0.0f, currentSpeed);
     ...
 }

I know "Time.deltaTime" is the time between last two "Update()".

Then why that code used "Time.deltaTime" in "FixedUpdate()"?

I know we use "Time.deltaTime" if we need to move something like kinematic with constant speed in "Update()". (like "transform.position += const_velocity * Time.deltaTime")

Of course, we use "Time.deltaTime" with "Mathf.MoveTowards()" or "Mathf.Lerp()" for smooth moving. But I think it is also natural in "Update()".

In my test, FPS is about 110~120 with large variation. Anyway, "FixedUpdate()" is called 50 times per second.

If there are 30fps and 120fps games, acceleration(=increase of velocity) of 30fps game is greater than 120fps game's. I think using constant like 1/120 is better than this.

I think "Time.deltaTime" is meaningless in "FixedUpdate()".

Is it just because the game is simple game and we cannot recognize the difference?

Comment
Add comment · Show 1
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 KoenigX3 · Jan 19, 2017 at 08:56 PM 0
Share

I agree with you that it is meaningless in the FixedUpdate().

However, when we are dealing with a 30fps and 120fps game, difference will only come if the physics handling is incorrectly set up in the Update() method.

As far as i know (based on the documentation), FixedUpdate() will always be called 50 times in one second. Update, however, can vary. If the AddForce() or other physics handling methods are set up in the Update() method, and are used without Time.deltaTime, they will apply a constant force in each update - making the 120fps game faster, since the player will have his object accelerated 4x more times. If Time.deltaTime is used in the Update() method, or the FixedUpdate() is used, they should have no difference.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by ErikHallmarkDev · Jan 20, 2017 at 03:01 AM

Despite what many people say, FixedUpdate does not run on it's own fixed time loop, instead it's called many(or no) times after the Update loop. This post does a much better job of explaining this than I could.

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 Play_Kim · Jan 20, 2017 at 04:50 AM

I did not check Scripting API.

In "Time.deltaTime" document, "When called from inside MonoBehaviour's FixedUpdate, returns the fixed framerate delta time."

In "FixedUpdate()", "Time.deltaTime" equals to "Time.fixedDeltaTime".

I solved my problems.

Thank you for all answers.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

space shooter tutorial issue "Ending the game" unity 2018.2 b 1 Answer

2d roguelike tutorial board manager issues 2 Answers

[HELP] Following the 2D character controller tutorial from the live training section (C#) 0 Answers

Space shooter tutorial, space ship keep moving and has interia 1 Answer

Value set in function doesn't update the glabal value 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