Example #1
0
    // sends the updated position of a player to other clients
    private void updatePosition(string message)
    {
        PositionUpdateMessage positionUpdate = JsonUtility.FromJson <PositionUpdateMessage>(message);

        foreach (RemoteClients remote in remoteClients)
        {
            if (remote.clientID != positionUpdate.clientID)
            {
                sendToClient(remote.clientEndPoint, positionUpdate.constructMessage());
            }
        }
    }
Example #2
0
    // Updates the location of position on the server and communicates it to all connected clients
    public void sendPositionUpdate(Vector3 position, Quaternion rotation)
    {
        PositionUpdateMessage positionUpdateMessage = new PositionUpdateMessage(localClientID, position, rotation);

        sendToServer(positionUpdateMessage.constructMessage());
    }