Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

How diffcult it is to make an online startegy game?

Discussion in 'General Discussion' started by II_Spoon_II, Aug 10, 2018.

  1. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Hello,

    So I am an indie game developper, I can manage making the game, I already made some games, but I was thinking about making it Multiplayer, is it so difficult than offline games?

    The game is simple, when playing PvP it has basic movements like chess or Tower defense, nothing fancy, so no lag problems I think, however, I don't know if I need any advanced programming skill? I have just average coding experience (1 year of coding).

    Can you guys pleas tell me what will I need? any tips? (ps: I am not gonna be hosting the game, I will use just Amazon or Unity services fo that, if you know any better alternatives let me know)
     
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    6,074
    It's much more difficult to make multiplayer games. You have to sync the game state somehow and do it with the minimum bandwidth usage as infrequently as possible without introducing gameplay issues.

    Chess and Tower Defense are wildly different in terms of multiplayer design so you'll need to be more specific.
     
    dogzerx2 likes this.
  3. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Thank you,
    The game consists on attacking other player towers, you select your troops and select one of his towers to attack, the attack won't consist of too much animation just very little ones.

    The player will have a personal profile with a bunch of agents he can buy, but nothing complicated.
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    3,593
    If you take the amount of time you expect a single player version of that game to take to complete, multiply that by 3, you'll have a rough guesstimate of how much time the multiplayer version will take to complete.
     
  5. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    3,817
    If it's turn-based, it won't be too hard. If it's real-time, prepare yourself for a grueling battle . The hardest thing in real-time multiplayer is syncing two different clients (or a client and a server) that are separated by, e.g. 0.1 or 0.2 seconds of network transit time.

    For example, if the player hits a button, it would take lets say 0.1s for the action to get to the server, and 0.1s more to get to a fellow player. That's way too long for a fast-paced game. So depending on your game, you have to make all sorts of predictions of the future, controlled de-syncs and re-syncs, the ability to rewind the (entire) game state (particles, animations and all) if your prediction is wrong, and all sorts of other meddling into the fabric of space and time.

    And in case you get through all of that, you will likely hear crickets on your server a week after launch.
     
    Martin_H likes this.
  6. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    91
    This, if you're a small indie studio/person I don't recommend making a multiplayer-only game. At the very least, put in bots (good enough so that one wouldn't get bored only playing with bots) so that the game wouldn't die instantly on launch.
     
    Billy4184 likes this.
  7. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    It's an RTS game, you move your units in the game, but not with turn, both players can move the units any time in the game, for example baloonTD on mobile, the 2 players play at the same time.
     
    Last edited: Aug 11, 2018
  8. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    The game is a tactical one, I think the bots should be really smart with a lot of code lines for each level, you think it's still easier than multiplayer?
     
  9. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Even if I make it a peer to peer? not client/server?
     
  10. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    12,311
    Choosing peer-to-peer over a client/server architecture won't necessarily make it easier. It'll just change the problems you will have to solve. One immediate example that comes to mind being how will you handle people who are behind a NAT.
     
  11. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103

    So for and indie with not large experience in Network, it's gonna be a waste of time to make a multiplayer?
     
    Martin_H likes this.
  12. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    12,311
    Only if by "waste of time" you mean "I don't have sufficient time to learn how to do it while making it".
     
  13. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Nah actually I have time, I have one free month ahead (I can work on it more than 5/6hrs a day) + after I can manage to work on it 1h -2h per day,will that be suficient?
     
  14. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    If anyone knows the steps to make a multiplayer, can you please write them down? just the general steps and I will look more into them, just so I have a better prespective, I wanna know eveything I will need, will be really halpful
     
  15. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Lockstep might be the way to go. Maybe check that out?
     
  16. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Is it less complicated?, I've seen that's its not used anymore, u ever worked with it?
     
  17. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,660
    Lockstep simply trades one set of network problems for a different set. It solves the problem of needing to send large amounts of data across the network. It solves the syncing issues. It largely solves issues with cheating.

    But at the same time it introduces its own issues. You will need to make your system entirely deterministic. Unity is not deterministic in the slightest. That means rewriting physics, random, frame handling, time and so on. Its not a job for the faint hearted.
     
  18. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Allright, so what do you think is the best option for a unity RTS?
     
  19. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    3,593
    You should start by researching the available networking API's. Maybe try out a few of them. Unity has deprecated the built in Unet API, and has not released its replacement, so I'd recommend going with a 3rd party API or writing your own socket implementation at this time.

    Generally you're going to have to design your game with consideration for:
    * How you sync the game state between the players
    * How your game will tolerate various levels of network latency
    * What data should be sent reliably, and what data should be sent unreliably
    * What network architecture you're going for
    * How to limit the impact of cheaters
    * How you will implement match making
    * If a player hosted architecture, how you will allow a player to host the game behind their firewall or NAT router
    * How you store and authenticate any player accounts, if any
    * How you will store and update any player progression, if any

    Depending on how you want your game to work, there could be a lot more, or some of the above could be ignored, but that list should be a good start.

    I'd probably take a look at Photon first, since it is generally well regarded, handles some of the issues above on its own, and has a low CCU free tier you can use while your game is in development.
     
    Billy4184 and Ryiah like this.
  20. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    12,311
    You have two basic paths available. You can approach the problem in the manner outlined by @Joe-Censored where you research and learn how to build your own solution. Alternatively you can use an existing solution from the Asset Store.

    A quick search of the Asset Store turned up "RTS Engine". It's a complete framework for creating an RTS with support for multiplayer using Unity's current networking solution. It's received good reviews and has been updated within the past couple of weeks showing the developer is still actively supporting it.

    https://www.assetstore.unity3d.com/en/#!/content/79732

    Unity may have deprecated it but the community has continued developing it. It's had a number of bug fixes as well as improvements and some of the limitations (eg SyncVars) have been lessened.

    https://forum.unity.com/threads/unet-hlapi-community-edition.425437/
     
  21. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    3,593
    The community has continued developing the HLAPI, but the low level API it sits on top of is closed source and also deprecated. Though I saw recently that vis2k is now working on his own LLAPI.
     
    Ryiah likes this.
  22. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Alright thank you very much, was really helpful, alot of information to look for, I'm starting rn :D
     
  23. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Solution like what? Photon for example?



    Yeah I tried this asset, their multiplayer support may be enough?

    Thank you very much, really appreciate your help ^^
     
    Last edited: Aug 13, 2018
  24. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    6,485
    Check out some of the Unity integrated multiplayer services they should have good turn-based examples you can extend to make the game you want.

    You could even base your choice on the multiplayer turn-based system with the best unity example.

    The thing is though if it's going to take more than a couple of months to make your game then you might want to hold out for the new networking system as this will probably be ECS based/integrated and therefore much more performant (reduced CPU load).
     
  25. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103

    alright thank you, after finishing the game, can I hire someone to do the netwroking thing? do people offer such a service?
     
  26. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,660
    Networking needs to be done first, or at least very early on. It tends to worm its way through every single line of code you write. Adding in networking after the game is done is hard.
     
    zombiegorilla, Joe-Censored and Arowx like this.
  27. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Then I think maybe I should save my game till I fully understand the networking process, thanks you for your help ^^
     
  28. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    6,485
    I would say no to this approach, you are putting something off you want to do. Just jump into it, find the best turn-based Unity example you can find and try converting it to a minimal viable product of your game.

    Networking needs to be built into the game from the get-go as none networked games run against the Unity engine networked games need to run via the server/PvP network. It's another layer to everything you do in your game.

    The upsides of net based games are they allow your game to become more abstract e.g. 'command' based as opposed to action/API call and event-based.

    I had a play with networking and managed to make this game even though I was new to Unity...





    It's not very good as a game but it was fun to make a multiplayer game and it was not that hard, just a different way of developing a game.
     
  29. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103

    Thank you , that's what I needed to hear, that it's possible to make, I started looking into networking, I will to do my best ^^
     
  30. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,660
    You should also stop changing your mind every time someone makes a new forum post. :p
     
  31. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    2,953
    It depends on how well designed your core architecture is. Our game started out as a sand box single player game. Then the game H3VR came out and we changed track. Most of the core design around our firearms, items and interaction was already done.

    After two weeks of working on our netcode we had this little demo on reddit :p

     
  32. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Yeah you are roght probably xD I just didn't know anything abt networking, but now, its dosen't seem that hard
     
  33. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    what do u mean by core architecture?
     
  34. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    3,593
    Uhhh ohh....

    ;)

    It refers to the backend design of all your game's core systems.
     
    AndersMalmgren likes this.
  35. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,660
    It means you need several years more experience before tackling online multiplayer.
     
  36. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    3,817
    @mehdi_barca10 download Photon or something like that and play around with their example projects. If you can understand them and modify them for your own purposes, you'll have a good chance of making it. No one can tell you if you're going to be able to do it, you'll have to find out for yourself. And never, ever follow online advice when you can easily try and see.

    Here's my suggestion. Make a game where:
    • One player has 5 cubes that they can move around in the scene
    • The other player has 5 spheres they can move around in the scene.
    • Sync the cubes and spheres on both computers in real time as the players move them around.
    That should take only a day or two. When you have done that, you can come back with some specific questions that you might actually get a useful answer for.
     
    AndersMalmgren, Ryiah and Kiwasi like this.
  37. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    2,953
    Like the other guys have mentioned its the core game logic, often refereed to as the domain. If you create a modular domain with high cohesion and low coupling its much easier to extend your domain with new features, like multiplayer.

    This is a very common mistake by many devs, seniors and junios alike. Though seniors do it in a lesser fashion. Its called Technical debt and we all do contribute to it. Thats why its so important to constantly revisit your code and your teams code (for example through code reviews) and refactor code smells. If this is not done you will reach a point when even simple features are hard to implement.

    I did a tutorial for our game. In all honesty I do not think I changed a single line of code in the existing domain code, the tutorial could just jack into the domain code through the different components but also by using the event bus. It was this easy because we have a high test coverage, and testable code often also are easy to extend like this.

    Here is the tutorial if of any interest
     
  38. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Allright thank you very much, I will look into that ^^
     
  39. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Hey, I was able to make this game in like 1 hour and half, and it was actually really fun (using unity networking scripts), I tried the game on LAN and on Network (matchmaking) and it worked fine.

    I still have many questions (sorry if they are a little bit indirect I never did networking)
    1-If I use uNET, will hosting the game on my computer (as server) do the job? or I need to buy a server?
    2-My player won't be making any movement, there will be just characters spawning when the player clicks somewhere, but their movements will be automated by scripts. I think then those charcters will be controlled by the server right?
    3-For the match making, I don't want to set rooms, I want the opponent to be chosen by the server, how can I accomplish that?

    Thank you ^^
     
    Billy4184 likes this.
  40. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    3,817
    Great! Did you implement smooth motion with acceleration and deceleration, and match the position within a very small margin, in realtime, on the other client?

    1) I only have experience in Photon, but UNet should be pretty much identical. There are two main methods that I know of for the way clients are connected.
    • The computer that creates a room (the Master Client) has some amount of authority over the other clients in terms of ensuring that cheating does not occur etc. The idea is that whoever creates a multiplayer game room for others to join will soon find themselves playing alone if they cheat.
    • A server is used to synchronize and validate the game state across different clients.
    Which one you use is up to you and your goals.

    2) Again, it's up to you. Since that's an avenue for cheating, it would definitely need to be validated by the master client or the server, depending on how you set things up.

    3) That's something that you'll have to learn by going through the UNet documentation.
     
    II_Spoon_II likes this.
  41. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Thank you for the fast reply,

    I didn't want to host the game on a player machine cause it's a mobile game, the CPU's ain't that strong even tho the game is basic, I'm afraid it will occure in crashes if the host had a weak CPU or he is using it in the background, do you think I may be facing that sort of problems (crashes) when hosting on a user mobile (using the punch through architecture) ? EDIT: when entering a game it's just a 1 v 1 game, not more.



    I didn't want to use photon just because it's not aware of Unity architecture (or at least that's what I found in forums), using it will make it alot harder for me specially that I am new to networking it will require alot more code.

    Thanks :)
     
    Last edited: Aug 16, 2018
  42. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    3,817
    Select a 'minimum specifications' device that you'll target with your game. Then test, optimize, repeat, until it all works smoothly.

    Not sure what 'not aware of Unity architecture' means exactly. Photon is designed to work with Unity.
     
    II_Spoon_II likes this.
  43. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Means that you have to rewrite rigidbodys and collider, to be more specific, unity physics
     
  44. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    12,311
    You're misinterpreting it then because the official tutorials for Photon show it using the physics built into Unity.

    https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/pun-basics-tutorial/intro
     
    Billy4184 likes this.
  45. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    3,817
    The non-local clients (i.e. the 'other' players on your computer) obviously cannot use physics because that would cause all sorts of problems when trying to force them to sync with the data coming over the network.

    The way it's done is to make the non-local client's rigidbody a kinematic one. Then you stream all the rigidbody data you want over the network (which comes in data packets spaced by e.g. 0.1-0.2 seconds), such as position, rotation, and also things like velocity and angular velocity if you want to make predictions between the arrival of data packets.

    Check out the Photon Rally tutorial. It provides a good foundation for doing this, although they lerp the position of the cars and this is nowhere near good enough for the speed of the game, with the non-local cars always being well behind where they should be. That's where prediction can come in.
     
    Ryiah likes this.
  46. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    Okey thank you :) I will look into that, really appreciating all the help you've been providing ^^