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 alexlam127 · Aug 30, 2013 at 09:06 AM · basic

How to make counter still counting after application has quit?

just like the building worker in clash of clan the counter still work when the app is closed .how to achieve that???

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
1

Answer by fafase · Aug 30, 2013 at 09:08 AM

I guess you want to do something like those game that keeps track of time even though you are not playing.

Well, the game is not running, the game stores the time you quit and stores only that. When you come back, the game compares what time it is now and what time was it when you left. Then depending on that time, it applies various changes.

In order to get the time you use the DateTime structure.

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 bubzy · Aug 30, 2013 at 09:12 AM 0
Share

damn ninja :D

avatar image alexlam127 · Aug 30, 2013 at 09:45 AM 0
Share

i have tried System.DateTime.now but i found that the time is dependent to machine.. so it is very easy to cheat the game.. any suggestion?? thx

avatar image fafase · Aug 30, 2013 at 12:09 PM 0
Share

Then you have to get the information from the net http://stackoverflow.com/questions/6435099/c-how-to-get-datetime-from-the-internet

avatar image alexlam127 · Aug 30, 2013 at 12:53 PM 0
Share

thx for the replay,but the code in above link do not work in unity i got lots of error...

avatar image bubzy · Aug 30, 2013 at 12:55 PM 0
Share

sadly, coding is more than copy pasting from the internet, you will have to read and understand what is being explained in the link and transfer that to unity code.

Show more comments
avatar image
0

Answer by bubzy · Aug 30, 2013 at 09:11 AM

you could have a time based variable that is saved when you quit the app, and then when you reload the app you can calculate how much time has passed since it was closed, then run your simulation based on the amount of time that has passed.

So it takes 1 day to build a house, you start building a house then quit the app at 07.00, then you reload it at 19.00, when you reload the app you calculate that 12 hours have passed, this would mean that your house is 50% complete, you can then alter the current state of the building to 50% complete. there may be another way to do 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 alexlam127 · Aug 30, 2013 at 09:36 AM 0
Share

thx for above 2 answer but what function can i use to achieve that? http://docs.unity3d.com/Documentation/ScriptReference/30_search.html?q=time cant found anything relevant to it..

avatar image hellaeon · Aug 30, 2013 at 12:20 PM 0
Share

To save stuff on the phone use PlayerPrefs You can use this class to store and retrieve your 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

19 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

A node in a childnode? 1 Answer

How to Name Individual Buttons Within a List 2 Answers

Flipping textures 0 Answers

yield return WWW; not returning 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