UNET Spawn with Client Authority

Hi guys, how can a client have more than one object?

I have this simple code:

void Start () 
	{
		Debug.Log("HAS AUTHORITY: " + hasAuthority.ToString());

		if(hasAuthority == false)
		{
			Debug.Log("Destroying the ENTITY");
			Destroy(this.gameObject);
		}

		CreateAvatar();
	}
	
	public void CreateAvatar()
	{
		GameObject avatar = Instantiate(PlayerAvatar) as GameObject;
		NetworkServer.Spawn(avatar);
	}

This is object was created as “The Player” and the authority is correct, every connect client has authority over its Player, but how can I get authority over the spawned “Avatar”?

Everytime it says I don’t have authority over the spawned object, this is the “Avatar”

	void Awake()
	{
		if(hasAuthority == false)
		{
			Debug.Log("Disabling the Movement because I am not the Owner of this");
			this.enabled = false;
		}
	}

Cheers

In Unity 5.2, they’re adding in functionality for non-player objects that can have Client authority. https://unity3d.com/unity/beta/unity5.2.0f1

For your case, you’d just replace NetworkServer.Spawn with

NetworkServer.SpawnWithClientAuthority(avatar, gameObject);

With 5.1, I don’t think it’s possible to have local authority on an object unless it’s a player prefab. Though you can have multiple player prefabs, if that helps.