I have never used it, and the documentation at http://docs.unity3d.com/Manual/UNetActions.html doesn’t make much sense to me.
I have used commands and [SyncVar] to manually change position of my players on all clients.
My main goal here is to send a sbyte[,] from the host player to any client that joins (only just once when they join).
I could change this to a string if needed.
The way I imagined this working is that in the start() method I could call a command and it would tell the server to send the array back to them. I have no idea how this would work though.
I had been following a tutorial to set up the position synchronization, and I also have a question about the following code:
Code
[Command]
void CmdProvidePositionToServer(Vector3 pos){
//Debug.Log ("syncing position");
syncPos = pos;
}
[Command]
void CmdProvideRotationToServer(Quaternion rot){
//Debug.Log ("syncing rotation");
syncRot = rot;
}
[ClientCallback]
void transmitTransform(){
if(isLocalPlayer){
if(Vector3.Distance(myTransform.position, lastPos) > posThreshhold){
CmdProvidePositionToServer (myTransform.position);
lastPos = myTransform.position;
}
if(Quaternion.Angle(myTransform.rotation, lastRot) > rotThreshhold){
CmdProvideRotationToServer (myTransform.rotation);
lastRot = myTransform.rotation;
}
}
}
Why is it that you cannot just set the synced variable in the transmitTransform() method?