Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Idle Coroutine question

Discussion in 'Multiplayer' started by Seraphrattle, Mar 26, 2021.

  1. Seraphrattle

    Seraphrattle

    Joined:
    Feb 16, 2021
    Posts:
    5
    [Post edit: I actually got upto some info about newtworks & seems I was asking more than I realised in the wrong way & would take way too long to answer. I now know I need a network "player" script lol kinda useful that 1 when creating an online game.]

    Ok so I'm practically green twig new. I've been looking for a week on info on how a network handles coroutines & can't find any so I hope this is in the right thread (soz if not)
    I'm looking to make a multiplayer online idle clicker, basically all UI. What I don't understand is whether I should handle the coroutines on the client or is there a way to sync them to the server to be saved. I'm looking at this thinking of it as a syncvar while thinking can I use a coroutine in this same way. Every piece of info I've seen has the client handling the coroutine (I haven't seen any info on syncing a coroutine as I haven't found any info on networked incremntal idle clickers) but to me this seems like a way the code could be hacked, which matters in this circumstance being a multiplayer online game but that is another matter for another time. A little expansion on what I mean: The player incrementally earns an amount >> I want to store that amount on the server (and then handle that amount as you would with any multiplayer online game.) I'm just running this on my own pc for now but I want to have the network structure there so I understand it & incase I decide to use it.
    This is a learning project for me & meant more as a a way to get my ideas down so I can explore them more & I'm stuck at my first hurdle by this seamingly simple matter.
     
    Last edited: Mar 26, 2021
  2. u-doug

    u-doug

    Joined:
    Jun 6, 2017
    Posts:
    11
    You definitely don't want to use coroutines for this kind of thing - a more fundamental problem would be if the player closes and re-opens the game whilst waiting for a timer to count down, that coroutine would no longer exist. The simplest, non-multiplayer way (still 'hackable') would be to base granting items off the system clock, i.e. when a player buys an item unlock at time X.

    If you're serious about creating this type of game you'll need an online backend to handle this kind of thing, of which there are a few, but the easiest one to get started with (in my opinion) is PlayFab. It's free until you have a lot of users and is pretty easy to learn the basics. Depending on your skill level it may take a few weeks to get an understanding of how it works, but a BaaS is essential for this kind of game unless you keep it totally offline.

    After learning about basic setup this is where you'd also want to look: Economy