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 ZeroKitsunei · Oct 14, 2012 at 08:19 AM · timesystemclockunitinterval

Smaller Time Interval?

I know Time.time keeps track of seconds in Unity, but is there a smaller timer available similar to System.currentTimeMillis() or System.nanoTime() in Java?

In general, the question is just for inquiry. But I suppose in practice it could be used to keep time scales in sync across all devices with different cpu clock speeds. That's the general application with the two mentioned above functions in Java since it too is cross platform. Or does Unity do this automatically?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Fattie · Oct 14, 2012 at 08:40 AM

To some extent I think the answer is "yeah it's automatic in Unity"

i encourage you to read this general answer about high speed real time networking in Unity (which is very very hard, as on any platform)

http://answers.unity3d.com/questions/329457/few-questions-regarding-multiplayer.html

U should also look in to realtimesincestartup, invokerepeating, and many questions on here about such time precision issues!

i never worry about anything less than the odd tenth of a second so don't ask me :)

TBC, "different cpu clock speeds" yes you utterly do not need to consider that. Unity absolutely, definitely takes care of that level for you :)

Could it be what you are getting at is the difference between Update() and FixedUpdate()

So, you have a car that moves. if you mistakenly use Update() incorrectly re the physics, etc, the car will indeed move at different speeds on different platforms. But FixedUpdate() will run at the same speed on different platforms, so the game will work correctly for everyone on the leaderboard!

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 Bunny83 · Oct 14, 2012 at 08:48 AM

Time.time is a float so it's numeric precision can vary depending on the length of the number but it's usually way better than your actual timestep you have between frames.

Unity, or most games in general, are frame-based. Time.time will not change during one frame. It only changes from frame to frame. A frame represent logically one infinite small step. This prevents inconsistency within the same frame. If you want to get a timedifference within one frame you can use Time.realtimeSinceStartup which does work frame independent.

You can also use the usual timers which comes with the .NET / Mono Framework. Keep in mind that not everything that is possible in .NET will work on all platforms.

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 ZeroKitsunei · Oct 14, 2012 at 09:14 AM 0
Share

Frame updates are great for rendering in games, but not so much for communications and logic, as Fattie pointed out, which need to stay constant across platforms. This was exactly my point too and his answer is closer to what I was looking for. Thank you anyway for the information! I honestly didn't even know C# had an HR timer.

avatar image Fattie · Oct 14, 2012 at 09:27 AM 0
Share

Bunny is drunk most weekends so don't worry too much about anything he says :-) (Between us ... schnapps.)

lol seriously I mainly just repeat info that B has told me over the years! :)

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

11 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

Related Questions

How Would I Change This To Read Within A Time Range? 1 Answer

How can I have timespan display less 2 Answers

How to impliment a 10 minute day clock, and tie it to a directional light rotation. 4 Answers

Digital clock 1 Answer

Unity3d School 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