Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[Need Suggestion] Time Control for Farm Game

Discussion in 'Multiplayer' started by nguyennk91, Sep 28, 2015.

  1. nguyennk91

    nguyennk91

    Joined:
    Sep 16, 2015
    Posts:
    10
    Right now i'm developing a farm game that have a global time (all user share same time)
    As the game have seasons, etc, as the game go on, player can start their game in winter time when they first beginning, etc

    Question: What is the best way to control time?
    Right now, i plan to create a webserver on my dedicated to control the server
    Code will run 24/7 and just sit there to wait for time request function from the app which will return the current time of the server
    This will be use to return the request for stamina regen as well
    The server will keep track of the last time the user regen their stamina, then when the request came for stamina regen, it will check the current time compare to the previous time, if it's correct --> change the stamina value in the database --> return the current stamina value to user

    Is this the best approach for this problem?
    Need suggestion for people who have already doing this type of time sync

    --------------------------------------------------------------------------------------------------------
    Updated my question :
    What solution should i use for this kind of game?

    I know how to setup a basic rest server c# to handle request but will that able to handle 1000+ players that requesting info at the same time?

    I research on google and saw that there are a lot of Network Asset like Ulink, Ugamedb, etc
    Anyone can recommend me which one is good for this type of game, and is scale-able if the player base grow?

    Thanks,
     
    Last edited: Sep 28, 2015
  2. TehGM

    TehGM

    Joined:
    Nov 15, 2013
    Posts:
    89
    The best approach is to request time from some dedicated time webpages.
     
  3. nguyennk91

    nguyennk91

    Joined:
    Sep 16, 2015
    Posts:
    10
    Can you give me some reliable time webpages so i can take a look?
    Thanks for the reply
     
  4. nguyennk91

    nguyennk91

    Joined:
    Sep 16, 2015
    Posts:
    10
    Updated my question :
    What solution should i use for this kind of game?

    I know how to setup a basic rest server c# to handle request but will that able to handle 1000+ players that requesting info at the same time?

    I research on google and saw that there are a lot of Network Asset like Ulink, Ugamedb, etc
    Anyone can recommend me which one is good for this type of game, and is scale-able if the player base grow?

    Thanks,
     
  5. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Sounds like my DarkRift (see sig) would be able to handle it but it really seems overkill for just broadcasting the time occasionally... I'm not sure I see why a good REST api wouldn't be able to cope so long as you weren't constantly requesting stuff though?
     
  6. nguyennk91

    nguyennk91

    Joined:
    Sep 16, 2015
    Posts:
    10
    well because of the mechanic of the game, each player prob will request at least 1 / second
    --> scale up 1000+ player = 1000+ request / second minimum

    I'm trying out gamesparks right now to see how it is XD
     
  7. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,796
    Look at GameSparks. They are a full backend server offering tons of features.

    They have system and clock counters on their servers you can use to trigger events, send notifications etc.
    You can store your own time variable in the database, and using their hourly or minute events, update the time in the database, and notify the clients, or let the clients request the time.
     
  8. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Store all time in UTC and do all calculations in UTC. Clients don't need to 'get' the time from anywhere, let them use their own time. You just make sure all actions that change data use your server time as being authoritative. If you are dead set on syncing time with the client, then just record the offset between client and server in UTC when the client first loads, and occasionally resync to account for drift.

    Clients pounding a server to update the time every second is completely not necessary, don't do that.
     
  9. nguyennk91

    nguyennk91

    Joined:
    Sep 16, 2015
    Posts:
    10
    Trying them now

    Thanks for the warning, will try your suggesion
    Now need to get familiar with nosql -.- only familiar with relational one lolz
     
  10. Katie-GameSparks

    Katie-GameSparks

    Joined:
    Oct 2, 2015
    Posts:
    13
    Hi
    Katie from GameSparks here.
    It sounds like GameSparks could help with your game.
    You can create events to trigger, collections to hold data, leader boards ,write cloud code and much more.
    We have tutorials online and our customer service team would be happy to help with any questions you have.
    Please email info@gamesparks.com for more information and we'll see what we can do for you.
    Cheers
    Katie