Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Yoshael · Feb 16, 2018 at 11:02 AM · c#timetimerc# tutorialmanagement

Time Management. Morning, noon and night.

Hi I am still very new to unity and was hoping to have someone point me to a tutorial or helpful hint that may help me out. :) Im trying to create a game that progresses time only when an action is done. Example, the player chooses to go to the shops in the morning so the game progresses to noon where they can choose another action. Ive tried to look for tutorials in time management but can only manage to find the real-time progression ones. Thanks :)

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 Alanisaac · Feb 18, 2018 at 10:23 PM

What I would do is use an enum to represent the time of day. I wrote an example script, showing how you can use a TimeManager class to progress to the next time of day (as well as keep track of how many days are elapsed). There's example usage of both, but the examples are very simple -- you'll need to figure out how you want to use the time of day and when you want your player to progress in your own game:

 using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
 using UnityEngine;
 
 public enum TimeOfDay
 {
     Morning,
     Noon,
     Night
 }
 
 public static class TimeManager 
 {
     public static int DaysElapsed { get; private set; }
 
     public static TimeOfDay CurrentTimeOfDay { get; private set; }
 
     public static void ProgressToNextTime()
     {
         switch(CurrentTimeOfDay)
         {
             case TimeOfDay.Morning:
                 CurrentTimeOfDay = TimeOfDay.Noon;
                 break;
             case TimeOfDay.Noon:
                 CurrentTimeOfDay = TimeOfDay.Night;
                 break;
             case TimeOfDay.Night:
                 CurrentTimeOfDay = TimeOfDay.Morning;
                 DaysElapsed = DaysElapsed + 1;
                 break;
         }
     }
 }
 
 // an example class doing something with the time
 public class GameManager : MonoBehaviour
 {
     // an example of using the time of day to return something different
     // your real "GetActions" would probably return a list of Action classes or something similar
     public string GetAction()
     {
         var currentTimeOfDay = TimeManager.CurrentTimeOfDay;
         switch(currentTimeOfDay)
         {
             case TimeOfDay.Morning:
                 return "Breakfast";
             case TimeOfDay.Noon:
                 return "Lunch";
             case TimeOfDay.Night:
                 return "Dinner";
             default:
                 return string.Empty;
         }
     }
 
     // an example of incrementing the time after an action
     public void DoAction(string action)
     {
         // here, the player's action is just printing debug info
         Debug.Log("Player did the action: " + action);
 
         // after the player does the action, use this to increment the time
         TimeManager.ProgressToNextTime();
     }
 }
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 Palanquinsg245 · Apr 22 at 10:46 AM

You know, the only thing I can advise you is to read some essays on time management. Here (https://papersowl.com/examples/time-management/) for example, you can read, see how people do, and learn about their experiences. In my opinion, this is better than any book. After all, experience immediately shows how to act, and how not.

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

129 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 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 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 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 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 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 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 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 avatar image

Related Questions

Clock doesn't stop when reaches 0.0. Can you help me with this. 1 Answer

How to create a timer that only increases when if command is true? 1 Answer

why the Timer isn't working 0 Answers

I make a timing score script in unity 2D, how i make high score of time?? Script is as follow: 1 Answer

Code Help Needed. Anti-Time Cheat System Not Working !!! 0 Answers


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