Looking for a UNET 5.2 video tutorial on spawning objects with client authority.

Does anyone know where I can find a video of this? If not, are there any other tutorials on spawning objects with client authority?

The documentations never give any examples on spawning objects. They would only go in detail and explanation on what it does, but no codes to actually show how to write the codes to spawn objects with client authority. Or codes that are written weirdly, like:

public void SetupClient(){    //Where do you place this at?
     //....
}

It tells you what to do inside the method, but it doesn’t tell you where you want to place the method in. But that’s all irrelevant for now.

If there are no tutorials whatsoever on the topics of spawning objects with client authority, how about let’s just collaborate and create a tutorial article on how to do this ourselves? By collaborating, what I meant was just publish whatever codes or knowledge we have so far, and share them altogether. And then I’ll try to re-organize them into an easy-to-read format.

If you want to spawn a gameobject with client authority, all you have to do is call this on the server:

NetworkServer.SpawnWithClientAuthority(gameObject, playerObject);

Where gameObject is the GameObject.Instantiate result (which used a registered prefab) and plajerObject is the client player object which you want to give authority to.

Where do you get that playerObject from, and from what methods/calls? That’s the main question I have since Unity 5.2 release. The docs never mention any of this.

Let’s say you have two players on your game: player A and player B. Each one has its own player object (that prefab that you check “local player authority”), say GOplayerA and GOplayerB.

Now, suppose player A wants to spawn a game object with client authority. First, you can let the server know about this desire through some [Command] function, and then you do, on the server side:

GameObject GOplayerA = GameObject.Find("GOplayerA");
GameObject objectWithClientAuthorityA = GameObject.Instantiate(clientGameObjectPrefab);

NetworkServer.SpawnWithClientAuthority(objectWithClientAuthorityA, GOplayerA);

Then, objectWithClientAuthorityA will be spawned on all clients, but will have client authority only on player A client.

Now, if you want to spawn a game object with client authority on all clients, I don’t think it’s possible.

1 Like

Thank you for your answers. So much helpful.

Wished I could like you more for this.