Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

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

Discussion in 'Connected Games' started by ARDMGameDev, Nov 10, 2018 at 10:59 PM.

  1. ARDMGameDev


    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.