Long story short, I swear I had this code working and then I went on a work trip for 2 weeks. I’m using ParrelSync to run two instances and the out of the box Mirror HUD to connect them together.
The error I get is:
Failed to spawn server object, did you forget to add it to the NetworkManager? assetId=1513053432 netId=2
I’m triyng to get players to connect as a player or a vehicle. Per googling, I made a base prefab (see code below) that swaps out the default prefab with one of two prefabs. I swear this worked prior to my trip but now, the server Unity instance will freeze and the client will give the above error. All prefabs have a network behavior and a network transform. These also work if I don’t do my “ghost” prefab and do either spectator or vehicle prefab.
public class GhostNetworkManager : NetworkBehaviour
{
bool DidSpawn = false;
void Start()
{
}
// Update is called once per frame
void Update()
{
if (!DidSpawn && NetworkManager.singleton.isNetworkActive)
{
SpawnCharacter();
}
}
[Command]
public void SpawnCharacter()
{
GameObject[] mainCameras = GameObject.FindGameObjectsWithTag("MainCamera");
foreach (GameObject cameraObject in mainCameras)
{
cameraObject.SetActive(false);
}
if (CommandLineArguments.Instance.IsSpectator)
{
var playerprefab = NetworkManager.singleton.playerSpectatorPrefab;
var newPlayer = Instantiate<GameObject>(playerprefab);
NetworkServer.ReplacePlayerForConnection(connectionToClient, newPlayer, true);
PlayerInput playerInput = playerprefab.GetComponent<PlayerInput>();
playerInput.enabled = true;
CharacterController characterController = playerprefab.GetComponent<CharacterController>();
characterController.enabled = true;
GameObject[] PlayerFollowCamera = GameObject.FindGameObjectsWithTag("PlayerFollowCamera");
PlayerFollowCamera[0].SetActive(true);
}
else
{
var newPlayer = Instantiate<GameObject>(NetworkManager.singleton.playerVehiclePrefab);
NetworkServer.ReplacePlayerForConnection(connectionToClient, newPlayer, true);
}
DidSpawn = true;
}
}
Probably unrelated, but I started getting these errors as well on startup:
Unable to add localization key: ‘UserNotFoundSignUp’: Requested value ‘UserNotFoundSignUp’ was not found.
Unable to add localization key: ‘VisitUnityDashboardToSignUp’: Requested value ‘VisitUnityDashboardToSignUp’ was not found.