banner



How To Increase Variable While Offline For Idle Game Unity

Search Unity

Unity ID

A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate in the Unity community.

  1. Hi! I have an android game that I'm about to make, and I'd like to ask how to create a certain feature found in idle games like Tap Titans and AdVenture Capitalist wherein you can gain currency even after you quit the game.

    I know it's impossible to actually create a script that runs after the game just so it can track the currency variable, but I just want to be given insight on what methods or ways I could implement this from a scripting perspective?

  2. Just thinking out loud here.. I have no idea about the games you mentioned, but
    You can just set the time when the user logs out (and back in) and calculate what kind of credits they might have earned in the interim. If your game also has a server, you'd be... (safer/better?) to calculate it server-side.
  3. Generally you record a datetime stamp and then when the user comes back on, you get a new datetime stamp and calculate what needs to be updated. (We're using this method in one of our games)

    As @methos5k said, a server side calculation is better, but if nothing else, just get a timestamp from a server. That way you don't have to use the device timestamp. But this depends on what your need is. You might not care if you just use local device timestamp.

  4. @methos5k
    I get you, those are just some games I have played so I used them as example.

    @Brathnann
    Can you explain to me how a server side calculation is done? Do I have to like, buy a server for that? I really have no Idea. and can you tell me how you used it in your games?

  5. StormHerald: You can either run your own, pay for a server, or you can connect to a server/service out there, if it's worth you doing this (i.e. to prevent the user from cheating.. doing things like setting their clock forward/back, for example).

    There are NTP servers that are often used to sync PC times. You could also find the time from some websites.. there's a few other solutions. There's downsides to doing it this way (ex., what if the service is unavailable??)

    There's some discussion on the topic here:

    https://forum.unity3d.com/threads/h...me-from-server-cloud-on-mobile-device.301027/

    FYI, I've never used this before, I just have seen it used for syncing PC time up before, and a quick Google search says people have done similar for gaming.

    Last edited: May 30, 2017
  6. We use playfab which has a free tier of service that works perfectly fine for us. We grab a server timestamp and use that for determine when a daily puzzle should be open, if a player should be able to view ads again to get free coins, those sorts of things.

    Since these are not really key gameplay elements, we don't do server side calcs, but Playfab does include the option to do server side code with javascript using their cloudscript system.

    Really it's based on your needs. But normally you grab a timestamp from the server at the start of the game. When a player quits, you add the amount of time passed to that timestamp(or grab a fresh timestamp). Then record that value.

    Then the next time they log in, use that value and calculate how much time has passed and process that however you need to.

  7. Thanks for the reply guys! I think I'm satisfied with the answers for now.

How To Increase Variable While Offline For Idle Game Unity

Source: https://forum.unity.com/threads/increase-a-variable-while-game-is-offline.473372/

Posted by: haygoodmarsou.blogspot.com

0 Response to "How To Increase Variable While Offline For Idle Game Unity"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel