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 ModSimTeam · Jul 03, 2013 at 10:36 PM · timetimertimescaledeltatimeaccurate

Accurate timing while using timeScale.

I have an entity moving between multiple waypoints using iTween. I would like to use timeScale to speed up/slow down the global time. I have a timer that increments based on deltaTime (timer += Time.deltaTime). When I run at timeScale 1 the entity gets to the waypoints at a certain time. When I change the timeScale the entity does not reach the waypoints at the same time. For example at timeScale 1 my entity reaches the waypoint in 1 min. At timescale 20 it reaches at 1min and 15 seconds. Is there a more accurate way of keeping track of time if I need to speed up the game play.

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

Answer by Kiloblargh · Jul 03, 2013 at 10:40 PM

 startTime = Time.time; 
 ... 
 timer = Time.time - startTime;

is always better to use than

 timer = 0;
 ...
 timer += Time.deltaTime;
Comment
Add comment · Show 2 · 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 ModSimTeam · Jul 08, 2013 at 02:47 PM 0
Share

I tried what you suggested but I get the same amount of error. The project i'm working on requires the users to fast forward and rewind while keeping track of time consistently and accurately. There seems to be a linear drift basted the current timeScale value.

avatar image castor · Feb 21, 2014 at 09:42 PM 0
Share

I was about to ask the same question! I have a similar problem with an agent using Navmesh.

I added a timer to see how long it takes him to complete the task:

 if (playerProperties.currentTask == GoToSleep){
         taskTotalTime += Time.deltaTime;
     }

 If timeScale = 1 I get a taskTotalTime = 17.5secs
 If timeScale = 80 I get a taskTotalTime = 71.5secs

I've also tried to fluctuate between different timeScales and always get different results. I cant figure out what "system" is getting broken with the timeScale changes...

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

17 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

Related Questions

How to shape time however I want? 2 Answers

Single Step (pause, resume), or externally clock game loop 0 Answers

Accumulating deltaTime oddity 1 Answer

TimeScale = 0 crashes Unity 1 Answer

How do I stop 'timeSinceLevelLoad' without pausing entire game? 2 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