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
1
Question by Michael4CG · Oct 04, 2019 at 09:36 PM · runtimebackgroundsimulationrealtime

How can i make the game keep running in the background on android/ios ?

Hi i'm working on a simulation game, like Sims and SimCity etc.. where player builds a city or people whatever, and then comes back next day to get his income etc..please any help

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 lgarczyn · Oct 04, 2019 at 10:11 PM

It's pretty simple, on launch you need to get the date using System.DateTime.now, compare it to a date you stored when the game last saved, and calculate the income for the time difference.

Comment
Add comment · Show 5 · 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 Michael4CG · Oct 04, 2019 at 10:33 PM 0
Share

Thank you for the good idea ! sadly, I don't think it will work with my game because it will allow players to have a way to cheat by changing the Date on their mobile devices. am i right ? What I plan to do is create a multiplayer game and I will use the PlayFab server to store players' data and so on. The only problem is that the method of collecting money or gold in the game is through workers who do a movement and transfer between two building, there are also many variables are linked to elements that use OnTriggerEnter To disburse resources and transfer them from one element to another randomly Also the coordinates of the elements (people, animals,etc) and their numbers change depending on the activity I don't think that the time variable alone will do enough to calculated all the variables

avatar image lgarczyn Michael4CG · Oct 04, 2019 at 11:33 PM 1
Share

You cannot force Android or IOS to keep your game awake, especially if it uses a lot of RA$$anonymous$$.

There is however another way than storing the date, and it is simply to send the date from the server to the application.

If you have a powerful server, it could keep updating the game in headless mode (no rendering), but that is pretty much overkill.

Just try to get the average time for a worker to get to his destination, and calculate that by hand. Or make your game independent from the Unity update system, and just run it really fast behind a loading screen.

avatar image Michael4CG lgarczyn · Oct 05, 2019 at 09:42 PM 0
Share

thank you this sounds great ! if i can run the game fast behind a loading screen using time taken by the server I will check this solution, do you have any reference or tutorial about that ?

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

112 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

Related Questions

Best way to get indoor lighting with shadows? 0 Answers

how to make rain smulation with accumulation on terrain model? 1 Answer

Export objects to a .3DS file at runtime 1 Answer

Specify background color of Gui.Button at runtime 1 Answer

Pre-rendered BG & 3d Character 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