void Update() { if (Net.GetState() == ENetworkState.Running) { float inputX = Input.GetAxis("Horizontal"); float inputY = Input.GetAxis("Vertical"); if (Net.IsServer()) { CubeServer.position = CubeServer.position + new Vector3(inputX, 0f, inputY) * Time.deltaTime; Data.Position = CubeServer.position; Data.Rotation = CubeServer.rotation; } else { CubeClient.position = CubeClient.position + new Vector3(inputX, 0f, inputY) * Time.deltaTime; Data.Position = CubeClient.position; Data.Rotation = CubeClient.rotation; } Net.BroadcastNetworkData(ENetChannel.Unreliable, Data); } }
public bool IsServer() { return(NetComp.IsServer()); }