Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 biohazard · Jul 22, 2011 at 12:13 PM · javascripttime

Realtime Clock? (needles)

Hello guys, i've got a clock with a needle for seconds and a needle for minutes, is there a predefined javascript function so i can have the right rotations?

i'm talking about a racing clock so it's not like tic-tac it needs to be a fluent rotation of the needle.

Any help is appreciated

thanks in advance

bio

Comment
Add comment · Show 2
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 biohazard · Jul 22, 2011 at 01:16 PM 0
Share

to bump or not to bump? this is the question

avatar image biohazard · Jul 22, 2011 at 02:41 PM 0
Share

B to the U to the $$anonymous$$ to the P ?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by tnetennba · Jul 22, 2011 at 03:03 PM

There is no predefined function for this. This is very simple mathematics and you will just need to apply linear interpolation to the needles rotation based on fixed time step. For example there are 60 seconds in a minute so:

360/60 = 6 degrees of rotation persecond.

And minutes:

360/ (60*60) = 0.1 degrees of rotation persecond.

Using these measurements you can then use linear interpolation between the two positions. http://unity3d.com/support/documentation/ScriptReference/Mathf.Lerp.html

Alternatively you can use the fixed update function. This is called a fixed number of times per second and can be adjusted in the edit->project setting -> time menu. That way you do not need to use linear interpolation as you know how far the needle will have to move every fixedupdate call. http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.FixedUpdate.html (see below)

Finally please stop bumping your questions every 20 minutes there is no need to do that as everyone can see the unanswered questions.

Comment
Add comment · Show 6 · 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 Eric5h5 · Jul 22, 2011 at 05:36 PM 1
Share

FixedUpdate is only for physics, and shouldn't be used for this sort of thing. For example, if you decide to change the physics update rate, then your unrelated code in FixedUpdate also changes how often it runs. Furthermore, in the event of low framerates, the maximum allowed timestep prevents FixedUpdate from running as often as it usually does, which means your clock will be wrong. So, never use FixedUpdate for anything except physics behavior.

avatar image tnetennba · Jul 22, 2011 at 05:52 PM 0
Share

Your right i forgot about the maximum allowed timestep. Disregard the last part of that answer.

avatar image biohazard · Jul 25, 2011 at 06:52 AM 0
Share

Code sample on mathf.Lerp? i don't seen to get this working :/

avatar image biohazard · Jul 25, 2011 at 07:04 AM 0
Share

when trying to $$anonymous$$athf.Lerp the rotation value between 0 and 360 using Time.deltaTime the needle gets stuck rotating back and forth

avatar image biohazard · Jul 25, 2011 at 08:22 AM 0
Share

How an i supposed to tell him to rotate 6 degrees every second?

Show more comments

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Finish One Combo 1 Answer

Keeping track of time? 4 Answers

Breathing sound effect using timers 1 Answer

How to save and display players times using Playerprefs in Javascript? 1 Answer

A node in a childnode? 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