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 Penanito · Jul 19, 2014 at 09:42 PM · programmingplatformer

Update, FixedUpdate, and deltaTimes...

I know there are alot of questions about these functions, and the confusion about deltaTimes...but with further research Im only getting even more confused :s

Just wondering if anyone could clarify how they differ?

If I understand correctly, Update is a simple call per frame, and using Time.deltaTime in an update function will give one consistent calling of that function regardless of performance? and FixedUpdate is a constant call primarily for the physics engine, since its constant, using Time.deltaTime in it would be useless...So then what would fixedDeltaTime be used for?

Essentially Im looking to find a way to update an objects position, adding to the x value constantly, to create an illusion of movement, but I want this speed to be constant, regardless of whether the client is using a toaster or a hyperspeed computer. Currently im using

 transform.position = new Vector2 (transform.position.x + (Speed * Time.deltaTime), transform.position.y);

in the LateUpdate() function, but since it is something that is dealing with physics, would it be better suited to be called in the FixedUpdate()?

Sorry if some of my assumptions are plain wrong, its just all a bit confusing right now

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by alwayscodeangry · Jul 19, 2014 at 10:10 PM

It actually looks like that code is doing exactly what you described :P

deltaTime is a measure of the time it took to process the previous frame. By multiplying any "per second" values (speed in your case) by deltaTime, you are inherently ensuring that the speed is applied consistently, regardless of how fast or slow your host device is running the program.

For example, let's say we have a speed of 10 and two devices, one running at 20fps and another running at 100fps. These devices would have deltaTimes of 0.05s and 0.01s respectively. On each update speed * deltaTime is applied to the position. So that's a speed of 0.5 and 0.1. Over the course of one second, the first device applies it's speed of 0.5 twenty times, and the second device applies it's speed of 0.01 one hundred times. In both cases the position is moved at a consistent speed of 10, independent of the device speed.

It's also worth mentioning that deltaTime is worth using on any single platform, as it also ensures consistent movement if the frame rate varies while the program is running (as it almost always does).

I hope this quick explanation helps, but a bit of googling on "delta timing" should give you lots more reading material :)

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 Penanito · Jul 19, 2014 at 10:16 PM 0
Share

Oh alright, Appears I wasnt that far off ^^. $$anonymous$$y biggest concern was that I thought that that line of code should be in the FixedUpdate() function, since it dealt with physically moving the object, thanks for the help though :)

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

23 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 avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Pause System not working :/ 2 Answers

how can i detect ledges for the player and make him get up 1 Answer

2D 360 degress platformer example needed 0 Answers

Spawn endless platforms help 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