- Home /
Multiplayer Client Missing Reference To Spawn Object
I've tried the multiplayer tutorial and I'm trying to spawn a Camera per player but on the Client side the Camera reference is missing, what am I doing wrong?
[Command]
protected void CmdSpawnCamera()
{
GameObject go = Instantiate(cameraGameObject);
_camera = go.GetComponent<Camera>();
NetworkServer.Spawn(go);
RpcSpawnCamera(go);
}
[ClientRpc]
protected void RpcSpawnCamera(GameObject go)
{
_camera = go.GetComponent<Camera>();
}
Answer by Killjow · Jun 25, 2017 at 11:14 AM
You cannot send a game object through an RPC call without adding a network identity. Also iirc you network.Spawn does not automatically add a network identity. Also make sure the camera is registered as a spawnable prefab.
Arguments to Remote Actions
The arguments passed to commands and ClientRpc calls are serialized and sent over the network. These arguments can be:
basic types (byte, int, float, string, UInt64, etc)
arrays of basic types
structs containing allowable types
built-in unity math types (Vector3, Quaternion, etc)
NetworkIdentity
NetworkInstanceId
NetworkHash128
GameObject with a NetworkIdentity component attached
Arguments to remote actions cannot be subcomponents of GameObjects, such as script instances or Transforms. They cannot be other types that cannot be serialized across the network.
I have everything setup like that and it doesn't work. I'm using unity 5.6.1f1
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
camera layer issue, multiplayer. 1 Answer
One camera in multiplayer? 2 Answers
Assign spawned object to SmoothFollow target 1 Answer
Multiplayer camera switch issue 0 Answers