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

Question Making an Asymmetrical Game on Netcode?

Discussion in 'Netcode for GameObjects' started by StrangelyCloudy, Feb 5, 2023.

  1. StrangelyCloudy

    StrangelyCloudy

    Joined:
    Jan 28, 2023
    Posts:
    3
    Hello! I am trying to make a new multiplayer game that happens to be asymmetrical (One team has four players, the other has two). I've been digging around in the documentation as well as the forums but haven't been able to find much about this question. I found ways to make players and then randomly assign them to teams, but not how to differentiate them based on model or allow players to choose which role they would like to play.

    To explain this a little more clearly - Say players A and B are supposed to be on team X, and players C and D are supposed to be on team Y. How can I make sure that all players are on their selected team, and give them their proper character model? Any help would be appreciated. Thank you so much!
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,533
    Just to be clear: NGO has no concept of „teams“. It‘s up to you to implement this. Let us know what exactly you are having issues with implementing this.

    Specifically, you have a client with a particular ClientId „X“ and he choses to play in Team B with Model K then you basically need to make sure the server gets this info when the game starts so the server can spawn the corresponding prefab K and records client X as member of team B.
     
  3. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    Hi @StrangelyCloudy , you can implement this at 2 stages:

    1. Matchmaking time: every players joins the matchmaker queue that is pertinent to the role he would like to play in the game. I.E: in a game where you have 5 players of which 4 are preys and 1 is a hunter, the hunter would join the "hunters" queue and the preys would join the "preys" queue before getting into the actual lobby.

    2. In the lobby: players decide their role once they connect to the game's lobby (I.E: by clicking a button to switch role).

    These are different approaches with different implementations. You can have a look at the official Matchmaker and Lobby services to see which one fits your case better.

    You can do this with a NetworkVariable that contains the ID of the model. When the value changes on the server, all clients will be notified and you'll be able to load the appropriate model.

    Does this help?
     
  4. StrangelyCloudy

    StrangelyCloudy

    Joined:
    Jan 28, 2023
    Posts:
    3
    Thank you so much! I'm mostly having trouble figuring out how to get the server to spawn in players on different teams with their appropriate models. Currently, I have successfully gotten the system to spawn in a player prefab with the right scripts. I just need to know what variables to write to get the game to change the team and model before the game loads.
     
  5. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    You can use a teamID NetworkVariable (a byte), players with the same teamID are in the same team
     
  6. StrangelyCloudy

    StrangelyCloudy

    Joined:
    Jan 28, 2023
    Posts:
    3
    Thank you so much! I'll implement this. I assume a similar function is used to set a variable for spawning in a different model? I think I understand a bit more and will report my progress!
     
  7. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    Yes, you can sync the ID of the model and use it on clients to retrieve the actual 3D model / prefab / whatever to show
     
  8. k3ndro

    k3ndro

    Joined:
    Dec 8, 2016
    Posts:
    28
    Hi, I wanna know if it's possible for Netcode to have VR asymmetrical game? VR can play with mobile via wireless LAN connection?

    I wanna know if it should be separate projects or just one. Thanks
     
    squallfgang likes this.
  9. squallfgang

    squallfgang

    Joined:
    Sep 13, 2016
    Posts:
    21
    I would to know that one too.