Search Unity

UDP/TCP Multiplayer (hot to spawn player, and set camera)

Discussion in 'Connected Games' started by ARDMGameDev, Nov 10, 2018.

  1. ARDMGameDev


    Nov 9, 2018
    Hi guys! I am making in C# dedicated server for my game. I cant make it "in-game" because i want it to be lightweight.
    My question is, how can i spawn player, and assign a main camera to the player?
    I mean, if i send packet with "spawn player", it spawns the object, but the player wont be playing as this object.
    Second question is:
    It is even possible in dedicated server (outside of unity)? Or should i do it in style: "Send to server spawn me", server sends to other players "your game should spawn this player" ?
    (SERVER Is not based on UNITY) bud just console project in visual studio,.
  2. Joe-Censored


    Mar 26, 2013
    I don't understand what you mean by "but the player wont be playing as this object." You'd include logic in your player object scripts that differentiates between the client that the player object is for and player objects that represent other clients. You'd then handle your inputs on the player object if that player object is the player object for that client. You'd also either instantiate the camera or reference an existing camera when you spawn that client's player object.

    It is certainly possible to build a dedicated server outside of Unity. You'll need to either create your own networking API, or use one that isn't specifically for only Unity.