This is the same problem as in http://forum.unity3d.com/threads/re...ms-to-be-broken-in-5-2-1.359149/#post-2785856
My problem is the following:
1) Assign client authority to object: AssignClientAuthority
2) Move object, that works
3) Apply RemoveClientAuthority and the object snap back to original position on client side. The "TEST" call is just to see if it apply to the last object.
Is this a bug or is it me who doing something wrong?
Here is a code example from a test i do:
foreach (string tagName in MP_Singleton.Instance.master_Object_List) {
temp_GameObject = GameObject.FindWithTag(tagName);
Cmd_LocalAuthority (true, temp_GameObject);
temp_GameObject.GetComponent<Renderer>().sortingOrder = z;
randomX = UnityEngine.Random.Range (-0.055f, 0.055f);
randomY = UnityEngine.Random.Range (-0.055f, 0.055f);
randomX = randomX + deckStartPosX;
randomY = randomY + deckStartPosY;
Rpc_Position (temp_GameObject, randomX, randomY, z, twistAngle);
// Add to depth
z++;
}
Cmd_LocalAuthority (false, temp_GameObject); //<< TEST
RPC:
[ClientRpc]
void Rpc_Position(GameObject myGO, float ranX, float ranY, int zDepth, float twist) {
myGO.transform.position = new Vector3 (ranX, ranY, zDepth);
myGO.transform.localEulerAngles = new Vector3(0f, 0f, twist);
}
Cmd_LocalAuthority:
[Command]
void Cmd_LocalAuthority(bool getAuthority, GameObject obj) {
objNetId = obj.GetComponent<NetworkIdentity> (); // get the object's network ID
if (getAuthority) {
objNetId.AssignClientAuthority (connectionToClient); // assign authority to the player
} else {
objNetId.RemoveClientAuthority (connectionToClient); // remove the authority from the player
}
}