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 /
  • Help Room /
avatar image
0
Question by KiritoSAO2 · Apr 12, 2016 at 05:41 PM · c#timertransitionslevel loadclock

How do I make a clock like in FNAF in Unity5?

Hello, I'm trying to make a clock like the one in FNAF. I'm trying to make it so the levels in my game start at 12 AM, and end at 6 AM but can't seem to understand how the concept or structure of the script is supposed to be used for this. The language I'm using is C#.

If I can get help or a script example as soon as possible, that would be great. Thank you!

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 M-Hanssen · Apr 12, 2016 at 07:23 PM

Here is a snippet from a analog clock I build in a project once:

 //*************************//
 // Created by Manu Hanssen //
 //     BlueTea BV 2015     //
 //*************************//
 
 using UnityEngine;
 using System;
 
 public class Clock : MonoBehaviour 
 {
     #region Variables
 
     public GameObject LargeIndex;
     public GameObject SmallIndex;
 
 
     protected int Hours;
     protected int Minutes;
 
     #endregion
 
     #region Unity Methods
 
     protected void Update()
     {
         if (Minutes != DateTime.Now.Minute)
         {
             SetHours(DateTime.Now.ToLocalTime().Hour, DateTime.Now.Minute);
             SetMinutes(DateTime.Now.ToLocalTime().Minute);
         }
     }
 
     protected void SetMinutes(int minutes)
     {
         Minutes = minutes;
         LargeIndex.transform.localEulerAngles = new Vector3(LargeIndex.transform.localEulerAngles.x, 360/60*Minutes, LargeIndex.transform.localEulerAngles.z);
     }
 
     protected void SetHours(int hours, int minutes)
     {
         Hours = hours;
         int hoursToSet = Hours >= 12 ? Hours - 12 : Hours;
         SmallIndex.transform.localEulerAngles = new Vector3(SmallIndex.transform.localEulerAngles.x, (360 / 12 * hoursToSet)+(360/12/60*minutes) , SmallIndex.transform.localEulerAngles.z);
     }
 
     #endregion
 }

Feel free to use or modify it!

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 KiritoSAO2 · Apr 13, 2016 at 02:49 PM 0
Share

Wow! That was fast! Thanks, I'll try this out right away.

avatar image nightwolf123501 · Oct 06, 2020 at 04:49 PM 0
Share

Is the Large Index and the small index text? Also, does this use real life time?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

HH:MM:SS game clock with modifiable start time error 1 Answer

How are those Resident evil/Silent hill type level transitions done? 1 Answer

Disable Ragdoll #C - Timer before disable. 2 Answers

,Why isn't the clock speed being affected by the float "clockSpeed"? 0 Answers

Time wont reset 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