Hi there, I am making a multiplayer FPS with Mirror.
I am following an old Brackeys tutorial, changing the obselete HLAP to Mirror.
Here is my player prefab window:
On both the client and the host side, I keep getting this message:
(Filename: C:/Users/Useraname/OneDrive/Documents/MultiplayerFPS/Assets/Mirror/Runtime/Transport/Telepathy/Server.cs Line: 82)
A game object can only be in one layer. The layer needs to be in the range [0…31]
UnityEngine.GameObject:set_layer(Int32)
PlayerSetup:AssignRemoteLayer() (at C:\Users*Username*\OneDrive\Documents\MultiplayerFPS\Assets\Scripts\PlayerSetup.cs:50)
PlayerSetup:Start() (at C:\Users*Username*\OneDrive\Documents\MultiplayerFPS\Assets\Scripts\PlayerSetup.cs:24)
This is PlayerSetup.cs:
//-------------------------------------
// Responsible for setting up the player.
// This includes adding/removing him correctly on the network.
//-------------------------------------
using UnityEngine;
using Mirror;
[RequireComponent(typeof(Player))]
public class PlayerSetup : NetworkBehaviour
{
[SerializeField]
Behaviour[] componentsToDisable;
[SerializeField]
string remoteLayerName = "RemotePlayer";
Camera sceneCamera;
void Start()
{
// Disable components that should only be
// active on the player that we control
if (!isLocalPlayer)
{
DisableComponents();
AssignRemoteLayer();
}
else
{
// We are the local player: Disable the scene camera
sceneCamera = Camera.main;
if (sceneCamera != null)
{
sceneCamera.gameObject.SetActive(false);
}
}
}
public override void OnStartClient()
{
base.OnStartClient();
string _netID = GetComponent<NetworkIdentity>().netId.ToString();
Player _player = GetComponent<Player>();
GameManager.RegisterPlayer(_netID, _player);
}
void AssignRemoteLayer()
{
gameObject.layer = LayerMask.NameToLayer(remoteLayerName);
}
void DisableComponents()
{
for (int i = 0; i < componentsToDisable.Length; i++)
{
componentsToDisable[i].enabled = false;
}
}
// When we are destroyed
void OnDisable()
{
// Re-enable the scene camera
if (sceneCamera != null)
{
sceneCamera.gameObject.SetActive(true);
}
GameManager.UnRegisterPlayer(transform.name);
}
}
My other scripts are attached below:
There is also a short PlayerWeapon.cs script that contains weapon information, however I feel this is irrelevant.
I also can not move on the unity editor. I imagine this is related to this issue, and will be resolved when this issue is.
5852992–621760–GameManager.cs (1.06 KB)
5852992–621763–Player.cs (692 Bytes)
5852992–621766–PlayerController.cs (2.16 KB)
5852992–621769–PlayerMotor.cs (1.87 KB)
5852992–621778–PlayerShoot.cs (959 Bytes)