Esempio n. 1
0
    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);
        }
    }
Esempio n. 2
0
 public bool IsServer()
 {
     return(NetComp.IsServer());
 }