• 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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

16 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

Related Questions

How to to do a progress bar wich scale down in 6 seconds ? (timeScale used) 0 Answers

Unity how to find load time? 1 Answer

How to get a time to persist across objects that activate and deactivate? 2 Answers

Game over scene when the time is up ? 2 Answers

Total Time Played since Installation 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges