Hello,
I read some tutorials then do some code using UNET. However i need some explanations about the code i made and UNet (synchronizations especially)
using UnityEngine;
using UnityEngine.Networking;
public class PlayerController : NetworkBehaviour
{
void Update()
{
if (!isLocalPlayer)
return;
var x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f;
var z = Input.GetAxis("Vertical") * Time.deltaTime * 3.0f;
// transform.Rotate(0, x, 0);
// transform.Translate(0, 0, z);
CmdMvt(x, z);
}
[Command]
void CmdMvt(float x, float z)
{
transform.Rotate(0, x, 0);
transform.Translate(0, 0, z);
}
}
i wanted to handle the transform only on server then synchronize it to the clients via the network transform.
I tried some scenarios:
- When i use this command with true on local player authority, only the host-client is updated
- When i update the position in function update without using command.and with true on local player authority, both are updated.
- When i use this command with false on local player authority this time, both are updated.
- When i update the position in function update without using command.and with false on local player authority, only the remote-client is updated.
I thought the first would update both.
I want to know why the network transform doesn’t update the positon and rotation from client to server.
I ask for clarification.
P.S. sorry for my english ![]()