Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Bug Why doesn't spawn work? What is the best way for me to create a player and a camera?

Discussion in 'Multiplayer' started by fladdyxx, Feb 28, 2023.

  1. fladdyxx


    Nov 10, 2022
    using UnityEngine;
    using Mirror;
    public class LobbyManager : NetworkManager

    public Spawn spawn;
    public GameObject MyCamera;

    public virtual void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    foreach (var cars in

    GameObject player = Instantiate(cars.car3, new Vector3(-0.1462975f, 26.15f, 80f),
    Quaternion.Euler(0,0f, 0));
    GameObject camera = Instantiate(MyCamera, new Vector3(-0.1462975f, 26.15f, 80f), Quaternion.Euler(0, 0f, 0));
    NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
    NetworkServer.AddPlayerForConnection(conn, camera, playerControllerId);