Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Reverend-Speed · May 28, 2017 at 03:15 PM · timetime.deltatimetimescaledeltatime

Why is my deltaTime wrapper slightly faster than time.deltaTime?

Hey folks.

I have a singleton GameController static script accessed by a Get property called Instance which contains a public float called dTime. In the Update method, dTime is assigned Time.deltaTime, with the intention of later multiplying this by a scalar value and creating an independent time scale (for bullettime, etc).

To test that this was working, I left out the scalar value and I used it to move the rigidbody component attached to my player character's motor script, like so:

 rbMotor.MovePosition(rbMotor.position + desiredDirection * speedCur * GameController.Instance.dTime

Weirdly, when compared to this:

 rbMotor.MovePosition(rbMotor.position + desiredDirection * speedCur * Time.deltaTime);

... the first piece of code (the wrapped Time.deltaTime) seems to move my character slightly, but noticeably, FASTER than the normal Time.deltaTime.

Further tests show that this effect happens with other game elements when I use dTime over Time.deltaTime.

(This is how I assign the dTime float in my GameController static class singleton...)

 dTime       = Time.deltaTime ;

I've used this technique in the past - it's usually very reliable. This time, however, it's being weird.

Has anybody idea what could be causing this? How can I fix this problem?

--Rev

EDIT #02: Okay, what the absolute fuck. Stuck a debug statement just above where the MovePosition code is called...

 Debug.Log("dTime is " + GameController.Instance.dTime + " and Time.deltaTime is " + Time.deltaTime);

... resulting in the following output in the console:

 dTime is 0.3333333 and Time.deltaTime is 0.02
 UnityEngine.Debug:Log(Object)
 CharMotor:MoveCharRelative() (at Assets/Scripts/Motors/CharMotor.cs:160)
 PlayInput:FixedUpdate() (at Assets/Scripts/Player/PlayInput.cs:51)

What the chittering hellfuck? dTime is OBVIOUSLY larger than Time.deltaTime, though they should be equivalent.

...

Nnngh. Could this be due to calling MovePosition in FixedUpdate, sampling dTime at a fixed period instead of getting a fresh Time.deltaTime when called to move... and thereby getting an arbitrarily high figure with dTime to multiply everything by?

Is this what I get for trying to call my rigidbody move position and rotate functions in fixed update?

I think I'll try creating a fixed update delta time, see if that works.

EDIT #03 - How weird. Well, I did as I said above, created a fixed update delta time called fTime (assigning Time.deltaTime in FixedUpdate()) and used this whenever I called a rigidbody MovePosition / MoveRotation command and... it seems to be working as a workable equivalent to Time.deltaTime. Caveat emptor, however - I'm testing this on a very crappy laptop, and it's possible I'm not seeing glitchy behavior above the machine's normal performance.

I think this might be the solution to this problem - in which case I'll write an answer for this in the near future. However, if anybody has any input or advice, would appreciate hearing it.

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
0
Best Answer

Answer by Reverend-Speed · May 29, 2017 at 11:59 AM

Solution seems to be as above (Edit 02/03) - create a second wrapper in your singleton, this time for Time.deltaTime sampled from FixedUpdate(). Use this when moving objects by Rigidbody Move functions and bob's yer uncle.

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

104 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 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 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 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 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

Farming game Time management 0 Answers

Is Time.deltaTime different on various devices? 0 Answers

Load scene after time 1 Answer

How to use time, when timeScale is 0? 2 Answers

Returning abnormal values with Time.deltaTime and Time.unscaledDeltaTime. 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