Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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);