UNET Scene Object RPC

I am writing a chat window. Child to the chat window is a Network component with commands and rpc’s for sending and receiving messages. With Legacy networking this works as expected, no pain. With UNet nothing I do works.

When I use a scene object with a NetworkScript I get this error on my clients

Trying to send command for object without authority.

So I look into spawning my network component on on startup…

And I learn that clients can not spawn objects…

I tried adding my NetworkComponenet to the NetworkManager “PlayerPrefab” and It is not spawning as expected either.

So… How exactly am I supposed to go about this ?

When I use a scene object with a NetworkScript I get this error on my clients
That because you are try to send command from GameObject without Client Authority.
Only GameObject spawn by NetworkServer.SpawnWithClientAuthority and any GameObject check with Local Player Authority checkbox in NetworkIdentity can send command to Server.
So I look into spawning my network component on on startup…
To spawn player GameObject :

Client side :

  1. Register this player GameObject to spawn system by :

ClientScene.RegisterPrefab(playerPrefabs);

  1. Set client to be ready:

    ClientScene.Ready(connection);

  2. Call server add player :

ClientScene.AddPlayer(connection,0)

Server side :

  1. Register addplayer listener ( if you using NetworkManager, just override OnServerAddPlayer function and ignore this) :

NetworkServer.RegisterHandler(MsgType.AddPlayer, OnServerAddPlayer);

  1. Instantiate player GameObject on Server:

    GameObject player = Instantiate(asset) as GameObject;

  2. Make client SpawnPlayer:

    NetworkServer.AddPlayerForConnection(netMsg.conn,player,0);

That’s all