AllocateViewID is not changing networkView owner

Hi guys,

I am trying to change a networkView object owner by changing its ViewID:

NetworkViewID id = Network.AllocateViewID();
networkView.viewID = id;

As long as I know the code above should change the network instantiated object owner for the client that created the the ViewID, but when I check if the object isMine it’s always returning false.

I want that when an object (a ball object) collides with another networkView player object, the ball changes its owner. Something like this:

void OnCollisionEnter (Collision collision)
	{
		if (collision.gameObject.GetComponent<PlayerScript> () != null  ! networkView.viewID.isMine) {
			NetworkViewID id = Network.AllocateViewID();
			networkView.RPC ("ChangeOwner", RPCMode.All, id);
		}
	}
	
	[RPC]
	void ChangeOwner (NetworkViewID id)
	{
		Network.SetSendingEnabled (0, false);
		Network.isMessageQueueRunning = false;
		
		networkView.viewID = id;
		
		Network.isMessageQueueRunning = true;
		Network.SetSendingEnabled (0, true);
	}

But the networkView.viewID.isMine always return false.

  • Sorry for my bad English. I hope I was clear enough.

Any idea ?

This is an old thread, but replacing:

by

networkView.isMine

makes it work to me (at least in Unity 4.6).