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 Rush3fan · Feb 08, 2012 at 11:10 PM · timeaccuracydelta

Delta time not accurate enough.. What should I do?

I'm having problems with syncing time with millisecond accuracy.

Here's what I did:

I started a game on my first computer with the time read out displaying.

I started another game on my other computer which is sitting right next to it with it's time also displaying.

I took a picture of both screens with my digital camera to see if they were close to the same time. They were very close.

I waited about two minutes and took a picture again. This time they had drifted off from each other by about 3 tenths of a second.

Something tells me I need a more accurate delta instead of Time.deltaTime

Anyone have any suggestions?

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 Rush3fan · Feb 08, 2012 at 11:14 PM 0
Share

I suppose I should be using doubles and not floats... However, Time.deltaTime is a float.

4 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Berenger · Feb 08, 2012 at 11:28 PM

Try System.DateTime.UtcNow, TotalSecond and those kind of things.

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 Rush3fan · Feb 09, 2012 at 12:56 AM 0
Share

No idea what you are talking about.. I looked those up in the script reference and found nothing.

Thanks for trying anyways...

avatar image Berenger · Feb 09, 2012 at 01:37 AM 1
Share

To be honest I've never used it. I found it in Aron Granberg AStar code, there was those line to profile his function performance (comments are an alternative):

//float startTime = Time.realtimeSinceStartup;

 System.DateTime startTime = System.DateTime.UtcNow;

 ... code and stuff to profile

 //Time.realtimeSinceStartup-startTime;

 lastScanTime = (float)(System.DateTime.UtcNow-startTime).TotalSeconds;

 Debug.Log ("Scanning - Process took "+(lastScanTime*1000).ToString ("0")+" ms to complete ");

avatar image
2

Answer by by0log1c · Feb 09, 2012 at 04:15 AM

You have mistaken what is Time.deltaTime. It represents the time elapsed since the last frame. It depends on zillions on factors, software, hardware, program running, etc and is in no way related to Unity syncing out.

You want to use Time.time which represents time elapsed since the start of the application.

What Berenger propose is part of the base .NET/Mono Framework on which Unity is running. You can find more info about it on MSDN. Note that it can also be done in JS, with the correct syntax.

Just thinking out loud: I can't think of a way to start a process on both computer with millisecond accuracy without 'manually' syncing them once they're running. Either you're pressing buttons or sending calls, both of which will be different no matter what, isn't it?

EDIT: oh yeah, you could have something monitor time closely and launch the process for you, duh.

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 Rush3fan · Feb 09, 2012 at 09:36 AM 0
Share

Well, actually.. it's synchronization via the network.. I finally found out that Time.time - as stated in my previous answer. I should have marked it as correct, but who am I to say my answer IS correct. I have no idea yet. I'll only find out in a couple days when I finish a bunch of ti$$anonymous$$g logic in my game.. That $$anonymous$$SDN link you gave me looks interesting though.. I will have to check it out.

Thanks!

avatar image
1

Answer by demented_hedgehog · Feb 22, 2015 at 05:34 AM

Time.time is the "The time at the beginning of this frame (Read Only)." So that's no good if you want to time something within a frame.

(Note: Environment.GetTickCount is not in unity?)

Possibly try Time.realtimeSinceStartup?

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 Rush3fan · Feb 09, 2012 at 04:04 AM

I think Time.time is my closest bet. I still need to work on some other problems with my synchronization before I start worrying about this again.

Thanks anyway Berenger.

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

fixed update and time.deltatime 1 Answer

change timer resolution of Windows 0 Answers

How can the animation of time bar become smoother? 1 Answer

Decrease Health every 5 mins or Time script? 2 Answers

Animation Control by frame (use Animation.State.time) 1 Answer


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