Search Unity

Basic advice on how to go about creating a turn-based game?

Discussion in 'Multiplayer' started by BusyRobot, Jul 6, 2017.

  1. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    I want to make a turn-based strategy game. It's something I've been wanting to do for a few years, and now a certain game I play daily could be shutting down I want to make at least some movement in the direction of creating the game. I've released a few Unity games on mobile over the years, so I have some coding knowledge.

    I've been looking into how to create a turn-based game (when I say turn-based I mean online) for over a year, but there doesn't be any straightforward way to making it happen.

    So for example there doesn't seem to be any assets that have online turn-based code built in.

    From my research it seems there two main options on the online side of things, and that's UNET and photon, with Photon seemingly the better option because it's been around for longer.

    But again even in Photon, there doesn't seem to be a lot of guides/help on turn-based stuff, not from the point of view of strategy games, and how to handle users, and the overall setup of how best to go about such a project.

    So my question (finally) is have I missed anything online? are there any guides/blog posts or even assets that will help me along the way?
     
  2. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Doubt you will find any step guides, rather you will find guides to Networking that you then have to use the knowledge to build your game. Network topics can often be large and complex and therefor the typical youtube tutorial usually doesn't apply to it.

    Pick a Networking library from your needs. Then start reading it's documentation. But what it all comes down to is to send over messages and call methods remotely.
    Such as: I just took damage. Let me tell the other clients that.
     
    BusyRobot likes this.
  3. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    Thanks for the info. I think what's confusing me, is there's the networking comms part, but then there's also people saying you need a database to hold data on top of that. I think I saw something called GameSparks mention in relation to the latter. Couldn't I hold the match data with Photon? I'd much prefer to keep everything under one roof so to speak, rather than having to split the calls up to 2 different places.

    And the other interesting thing in relation to what you said is, is doing turn-based online games that complex? i.e more complex than other types of online games which there seems to be a lot of info and assets for? I would of thought just having, 2 people taking turns to play a game would be a lot easier to pull off than anything in real time.
     
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    I think turn based games are some of the easiest. And photon and UNET are just Networking libraries. They have services that can hold data.
    Depends on the game. If you can hold the data on the server or even on clients. Then do that. But if you need external storage. Then look into something like that.

    As for finding assets, I almost never use external assets as I find them to often times be of poor quality and the really good assets I prefer to write my own version for to save cash.
     
    Deleted User and BusyRobot like this.
  5. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    I want to create something like Hero Academy, which is a game I've played for many years. Unfortunately it could be shutting down due to the change to 64bit apps.

    I'd happily buy an asset that does a lot of the hard work for me (networking, online stuff, not the actual game code), but there doesn't seem to be any. Plenty of real time ones though.
     
  6. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    UNET does the networking for you.
    You just have to hook it to the game code. Read the documentation on Unet HLAPI.
    Example:
    You want a variable to be synced across all instances. Mark it as SyncVar.
    Another example:
    You want to tell the other client it's their turn. Send a message to the server (refered to as a Command). And then make the server tell all the other clients (Known as a RPC)
     
  7. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    And you think UNET rather than Photon? When I read comparisons it seems people usually recommend Photon.
     
  8. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    I personally use UNET, I don't think Photon is really designed to be used with Dedicated Servers which my game uses. But I might be wrong.

    Read up on the two. I think Photon has cloud services that come with it automatically which will limit you and charge you. While UNET is just the networking and then there is Unity Multiplayer Services to add on to that if you so please.

    I usually don't like to take any sides and prefer things.
    I don't personally prefer Photon or UNET, but when our game was on the drawing board UNET was the more appealing option for our game.
     
    Last edited: Jul 6, 2017
    BusyRobot likes this.
  9. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    244
    Hero Academy is more aynchronous multiplayer than realtime.

    Like their backend is probably a database of users, games, and turns. And they probably have a server that can push 'turn ready' updates to connected clients. or they just poll a plain old web server every 15-20 seconds to see if they have a turn ready.
     
  10. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    Exactly, I don't need real time, but I still thought there would be advantages to using UNET or Photon?
     
  11. Severos

    Severos

    Joined:
    Oct 2, 2015
    Posts:
    181
    UNET is free, Photon is paid, that's the first concern right now I'd say, since you don't have multi player experience with either then both would make the same thing for you.
    Now, far as I remember (been a while since I used UNET) implementing "rooms" in UNET isn't a straight forward thing, so if you want to have multiple players playing in groups without affecting each others, it can be a bit annoying to implement.
     
  12. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Rooms are very straight forward in UNET if you use the Multiplayer Services.
     
  13. Severos

    Severos

    Joined:
    Oct 2, 2015
    Posts:
    181
    Oh, guess it's something new that I wasn't there when they added it...
     
  14. fvde

    fvde

    Joined:
    May 15, 2014
    Posts:
    19
    Some general thoughts regarding complexity: FPS style games - let's say always always syncing player and object locations - are often
    • more demanding in terms of network bandwidth, however
    • They recover from failure by design, as they move objects to their correct locations all the time
    • They are quite simple in terms of core logic - shoot, kill
    Turn based games on the other hand
    • Require almost no bandwidth in comparison, making them a good target for mobile
    • Need to be rock solid with regards to errors, as one error might propagate easily throughout the game
    • Tend to have more rules and complex states: turn transitions, consolidating player input, game logic
    With all that being said, I would recommend an authoritative server that encapsulates the game logic and quite light clients that only show state. However this approach would require you to have a good amount of backend implementation experience. I'm planning to implement a similar game and am looking forward to hear how it goes for you regardless of the approach you end up choosing!
     
    Last edited: Jul 9, 2017
    xVergilx and TwoTen like this.