Search Unity

UI Networking (UI Only Multiplayer Game) Help please

Discussion in 'Multiplayer' started by Tamoya, Mar 2, 2016.

  1. Tamoya

    Tamoya

    Joined:
    Jan 13, 2016
    Posts:
    11
    Hi I have been working on a game similar to Gwent from the Witcher 3. I have been working on this project for educational purposes and I've run into a bit of a dead end when it comes to the networking. I didn't think about networking until now and I think I may have shot myself in the foot with the way I set things up. In my hierarchy I used mostly UI elements on a single canvas for my game. I can't seem to get my 2 clients to show updates across each others screens. I have tried looking up several tutorials on networking, however I see that they all work with the 3D movement objects (first person / third person).

    Finally to my question: Is it possible to make a multiplayer game with nothing but UI elements? There will only be 2 players in a given lobby at a time, so I figured that the basic networking would suffice but to no avail.

    Screenies of my setup. Note: The one error in my Log is due to a character information object that loads from the previous scene not being there. Also, player 2 is empty for obvious reasons :p

    P.S. I just need some pointing of the correct direction :) thanks for reading and thanks for the help in advance.

     
  2. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    You can definitely create a multiplayer game with nothing but UI elements; it is precisely what I do in the demo game included with CCG Kit (which was also created as an educational tool to help create this type of games).

    It is hard to give you a more concrete answer by only having the screenshot as a reference and no other information on your current setup/code, but you are definitely going to need to explicitly write code to send updates between the server and its connected clients. There are several ways to go about this: from the more traditional one of having a central entity managing the game state (possibly living only on the server) receiving the player actions and replicating state updates at the appropriate times to every connected player, to one that leverages UNET's NetworkBehaviour and therefore simplifies the spawning of objects that are to be seen by every connected player. In the first case, the cards would only exist locally on each client and would reflect the latest information received from the server. In the second case, the cards would be network-aware entities (registered as an spawnable prefab in the Network Manager) automatically visible to all connected clients, which may be more convenient for later manipulations via commands and client RPC calls. Depending on the specifics, a mix of both approaches can also be useful in my experience.

    Even if UNET certainly simplifies certain aspects of multiplayer game development, it still is a complex topic. I would recommend tackling one area of the game after another following a logical progression; for example, starting with the turn sequence, where you would have one player being the active player at a given turn. This turn would end after a specified period of time or when the active player explicitly ends it (depending on your game design) and priority would be given to the second player. Implementing just this alone is an interesting exercise that will introduce you to some of the fundamentals of networked programming without directly tackling the additional complexity in managing the entire board state.
     
  3. Tamoya

    Tamoya

    Joined:
    Jan 13, 2016
    Posts:
    11
    In your third paragraph I see where you are going with that. I was watching a tutorial on the Unity Networking Modules, and I saw the person working with a car in 3D space being controlled by the player. I was thinking that it might not be possible with only UI elements, because that person and everyone else that i was watching was working with nothing but 3D objects. Thank you so much for your reply and letting me know that it IS possible for my game to go multiplayer for educational programming purposes. I do have another game in mind, completely original, that I'm using this game (Gwent from The Witcher 3) as a fundamentals project to better understand programming. Also, I'm currently attending college for Software Development, however I'm still in my first year first semester so I haven't learned any programming yet. I'm excited to get further into programming so that's why I'm working on this project.

    Again, thank you so much for your reply. :D

    P.S. I didn't show any of my code, because I'm not seeking coding help. I like to try and tinker with things and figure it out myself, because everyone has their own programming style. I may or may not understand someone else's programming style, so I'd like to try and understand it in my own way that makes sense and works optimally. With Unity, I'm learning new stuff everyday which I'm willing to bet will help me big time when I get to my programming courses in college.
     
  4. KingTooTall

    KingTooTall

    Joined:
    Oct 17, 2014
    Posts:
    61