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 NovacainE2 · Feb 09, 2017 at 04:04 PM · backgroundapplicationclosed

Game continue running after application is closed?

Hello guys! I at an intermediate level when it comes to Unity. Currently, I am building a 2d game for mobile with a zoo theme. What I want to achieve is for the game to keep progressing even if the player is out of the game. Ideally, the game continues to run entirely even if the game display is not there(game closed). For example, I want it to be possible for the dinosaurs in the zoo to contract some diseases if the player hasn't logged in for awhile or I want the zoo to keep getting dirty if the player has not logged in for awhile. For now, the game starts fresh every time I start it. How can I achieve something like this? Any guidelines I should look into? Thanks in advance. Any advice will be helpful. I've read about data persistence, but mostly it comes down to changing scenes through singletons and not when the game is closed.

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
2

Answer by HenryStrattonFW · Feb 09, 2017 at 07:55 PM

To achieve this, we don't actually have the game doing anything in the background, instead what you do is store a time when the game closes (typically you'll use the OnApplicationPause event for this). Then when the game next resumes, or boots up again, you check the time between now, and that time value you stored earlier.

With this time (lets say for example, 8 hours have passed). You then determine how much and in what ways to affect the animals in your zoo. Normally this would be based on something like animal hunger increasing by a value X per hour, etc.

Just make sure to check this data on both the application resume, and the application boot as both could potentially happen but you wont know which at the time of app suspension.

Hope this helps give you an idea of how to achieve this.

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 NovacainE2 · Feb 09, 2017 at 07:59 PM 0
Share

Hey @HenryStrattonFW ! Thanks a lot for your input. :) I will try and implement what you said tomorrow and let you know if it worked for me! Then I will accept this as the best answer! Again, thanks a lot!

avatar image HenryStrattonFW NovacainE2 · Feb 09, 2017 at 08:14 PM 0
Share

No worries, good luck with your project!

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Application Run In Background 1 Answer

Can I combine untiy with x-code? 0 Answers

How to make Editor fit on one monitor. 0 Answers

Upgraded to Unity Plus 2019.3.0f6 from Unity Plus 2019.2.15f1- apps now crash! 0 Answers

My clone objects behind background 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