Search Unity

Creating server which multiple clients connect to play separately in their own "rooms"

Discussion in 'Multiplayer' started by spvn, Dec 8, 2017.

  1. spvn

    spvn

    Joined:
    Dec 10, 2013
    Posts:
    80
    Hi I'm trying to create a simple server application that receives client messages and sends back validation messages. I want multiple clients to connect to the same unity instance, but each plays their own game session against a server controlled "AI" (mobile game). The player sees all the visuals on their screen, sends attack commands or whatever else to the server, the server then responds with the results of their attack.

    The server wouldn't need to operate a scene or any physics calculations, purely some simple logic. Initial thoughts are each player is linked to a specific prefab instance in the scene that manages that player's session, but this is flexible.

    The main question is how could I go about creating this using unity's networking features? 99% of the tutorials i've seen so far make use of network managers and both server and client running the same scene, and then syncing specific objects. I could do that for my game but it would be unnecessary for every single player to spawn their own unity instance because of how simple things are.

    Instead, I want multiple clients (each playing a scene with the visuals of themselves vs an enemy), connecting to a common unity instance that has no visuals at all and purely receives and sends commands.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    FrittoMisto99 likes this.
  3. spvn

    spvn

    Joined:
    Dec 10, 2013
    Posts:
    80
    That's actually really helpful! Didn't know about NetworkServerSimple. By Unet Messages do you mean the NetworkMessage class?
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'm talking about extending MessageBase. Here's the manual page that discusses it, but that example project does a better job.

    https://docs.unity3d.com/Manual/UNetMessages.html