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. Dismiss Notice

Adding Multiplayer to a Developed Game

Discussion in 'Multiplayer' started by Aimlessone, Nov 2, 2015.

  1. Aimlessone

    Aimlessone

    Joined:
    Jun 26, 2015
    Posts:
    46
    So I'm fairly new to Unity and C#, but I'm developing a turn based strategy game using a kit I purchased. The Kit only supports hot-seat multiplayer, but I'm looking to see if anyone has any insight on how difficult it would be to add online multiplayer to such a game.

    I'm sure it's possible to integrate, but since I know next to nothing about multiplayer scripting I don't know where to begin or have any idea how much I'd have to change with the original code. Any information to get me started would be greatly appreciated.
     
  2. arkhament

    arkhament

    Joined:
    Jan 24, 2015
    Posts:
    114
    Photon have online and offline mode, so you can switch your game, but first you need to convert all your game to online mode.. then with online line you can your game to offline mode(Single player - SOLO)
     
  3. Aimlessone

    Aimlessone

    Joined:
    Jun 26, 2015
    Posts:
    46
    Arkhament, thanks for the reply. I've looked at Photon, it looks like something I could use. My question is more along the lines of how much of my original code would I have to change in order for my completed game to be online multiplayer?

    The kit I used doesn't have any multiplayer support, so It's all centered around AI or hot-seat multiplayer. So this is where my ignorance comes in. I really don't know where to go from here.
     
  4. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Multiplayer flow is significantly different, you would most likely end up rewriting a large chunk of the codebase. I strongly suggest learning multiplayer on a different project. What you are attempting is for someone who already knows how to write multiplayer code. There is literally no simple answer to your question, it's a whole body of knowledge you have to learn through experience.
     
    Meltdown likes this.
  5. Aimlessone

    Aimlessone

    Joined:
    Jun 26, 2015
    Posts:
    46
    Snacktime,

    Thanks for confirming my suspicions. I think I'll spend some time just learning how to write multiplayer code on another project.
     
  6. Brainswitch

    Brainswitch

    Joined:
    Apr 24, 2013
    Posts:
    270
    It is also hard to say, without knowing the code of this kit you mentioned. And also without knowing how well you are familiar with the code of this kit. If it has hot-seat multiplayer already, I'd say it's probably one of the easiest game types to add (basic) multiplayer to. Still, multiplayer is not easy and as snacktime mentioned you might be better of learning multiplayer on a new project.
     
  7. Aimlessone

    Aimlessone

    Joined:
    Jun 26, 2015
    Posts:
    46
    Hello Brainswitch,

    The kit is called Turn-Based Toolkit (on the asset store here)

    It's unfortunate, because the whole purpose of this original game was to be online multiplayer not just hot-seat. But the further I got into development the more I realized that I may have gone the wrong route. I originally thought it would be best to get the game created, balanced, and working; then add a multiplayer component to it. Turns out I may have done it backwards.
     
  8. arkhament

    arkhament

    Joined:
    Jan 24, 2015
    Posts:
    114
    with photon you can re-code easy that game to multiplayer..
     
  9. Aimlessone

    Aimlessone

    Joined:
    Jun 26, 2015
    Posts:
    46
    Arkhament,

    Can you please expand on what you mean by easy? Please remember that this is my first ever project and it was done with a fairly easy toolkit. So my coding knowledge is still in its infancy, so "easy" is relative to the experience of the programmer. Considering I don't even know where to start, it's already difficult. Any specifics to how using Photon could be easy and get me to my desired goal on online multiplayer would be greatly appreciated.

    Thanks in advance.
     
  10. arkhament

    arkhament

    Joined:
    Jan 24, 2015
    Posts:
    114
    sorry I did not consider that part.. well.. In any case also could you do with another asset, take a look for the asset Forge in the asset store https://www.assetstore.unity3d.com/en/#!/content/38344
    Is much easier though photon, and possibly something you can finish your multiplayer game if your programming skills are basic yet.
    Here is a video where they are integrating an existing project to multiplayer mode https://www.youtube.com/watch?time_continue=29&v=NfUIr_g6ZAU

    Then tell me what you think :)

    Regards
     
  11. Aimlessone

    Aimlessone

    Joined:
    Jun 26, 2015
    Posts:
    46
    I read through the asset store descriptions but will have to look at the video another time. I did see that the description states in bold real-time multiplayer.

    I'm trying to add a multiplayer aspect to my turn-based game, so would this even work?
     
  12. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hello there!

    I am the architect behind Forge Networking :). Just wanted to thank @arkhament on the shout out. I would like to note that the "integrate into existing code" tutorial is one of our oldest tutorials. We do have a lot of new features and methods to make it easier. This does remind me that we need to update this tutorial with a new video :).

    The old AddNetworkedVariable and lambda expressions still exist for reasons that require that complex behavior but you can now use the [NetSync] attribute above the target variable instead. See this tutorial on how NetSync works.

    We have tons of developers who are absolutely new to networking on Forge and our community helps out each other every day! We (the Forge team) are active in the community daily and would be happy to help in any way possible.

    If you would not like to use forge, here is a post of mine to another user who was curious about making their own networking solution or working with networking (that isn't any of the plugin providers).

    Please let me know if you have any questions, it doesn't have to be related to Forge at all :). Feel free to ask me any questions about networking. I do not own the package that you are working with (or any kit that includes networking) so I am not sure of the particular strategies that are used within the kit. If you would like to tell me which kit you are using I may reach out to the developer on making a Forge Networking integration with it :D
     
  13. Aimlessone

    Aimlessone

    Joined:
    Jun 26, 2015
    Posts:
    46
    Farrisarts,

    My questions to you would be:

    1. As sated above, Forge states in bold real-time multiplayer so would it work with turn-based games?
    2. The kit I used is linked above in my response to Brainswitch, that's what my game is built off of (with a few tweaks)
    3. As stated in the OP, I'm new to networking so I'd have to look at tutorials to see how easily forge can be integrated into games. I would be wondering on average how much coding changes would be required.
     
  14. arkhament

    arkhament

    Joined:
    Jan 24, 2015
    Posts:
    114
    no problem @farrisarts, your asset is really awesome ;)
     
  15. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hello @Aimlessone :D

    Yes, I should edit the description of Forge so that it doesn't make that confusion to others as well, thank you so much for pointing that out. Forge Networking is built to work with every kind of networking, real-time, turn based, mmo, you name it.

    Awesome :D sorry I missed that post, I'll check it out asap!

    Yes, this is also why I was looking for the package to understand the level of effort better. It could be that the package in question is completely using the old legacy Unity networking, is so then it should be minimal effort. We may even make a plugin for it if so :)

    We also have tons of tutorials for Forge Networking and a pretty active community :). We are all open to brand new network developers. Of course I don't only wish to talk about Forge. If you think it is not for you, feel free to ask me any networking related questions, I'd be happy to help!
     
  16. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Most networking solutions like Forge or Photon are really for real time networking where you are sending updates every 20-60 ms. I don't know the details of the game you are looking at converting, but if it's literally just sending data to each player at the start/end of a turn, realtime networking is complete overkill and the wrong tool for the job.

    A simple http server that keeps some state and and just have the clients poll for information using the built in WWW class. That's what I would do. Grab your favorite web framework or just a simple embedded http server, whatever you are comfortable with.

    Or go signup with Playfab or GameSparks and use their free services and their cloud code, that's probably even simpler.
     
  17. Aimlessone

    Aimlessone

    Joined:
    Jun 26, 2015
    Posts:
    46
    The package doesn't use networking whatsoever, its only intended for AI and Hot-seat multiplayer, which is why i am here looking for the best way to convert it.

    Essentially this, however I would like my attack animations, character movement, and damage calculation to be done in "real-time" so as the players can see what their opposition is doing move by move. Maybe in this case Photon or Forge might be useful? Unless an HTTP server can handle that.
     
  18. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    In that case I'd say use Unet. Http doesn't really work well for syncing stuff quickly like that, and Unet has more built in support for sending Unity objects. Http is bettter if you just need to sync data you can say serialize to json, and only need to update like once a second or less.
     
  19. Aimlessone

    Aimlessone

    Joined:
    Jun 26, 2015
    Posts:
    46
    Thanks, I'll start looking at Unet documentation and tutorials.