Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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