/// <summary>
    /// Initializes this avatar script as the remote avatar. Activate RemoteAvatarScript. Deactivate camera and LocalAvatarScript.
    /// </summary>
    public void InitializeAsRemote()
    {
        LocalAvatarScript las = GetComponent <LocalAvatarScript>();

        las.enabled = false;

        GameObject cam = transform.Find("Camera").gameObject;

        cam.SetActive(false);

        RemoteAvatarScript ras = GetComponent <RemoteAvatarScript>();

        ras.enabled = true;
    }
Exemplo n.º 2
0
    /// <summary>
    /// Following receipt of a position/rotation message from the server, update the position
    /// of the remote avatar. Unmarshall the message (to obtain the position, rotation and
    /// animation information) and then perform the necessary updates to the remote avatar.
    /// </summary>
    /// <param name="message">Message.</param>
    void UpdateRemoteAvatar(byte[] message)
    {
        byte  avatarId;
        float x, z, r;
        byte  m;

        //--------------------------------
        Messages.UnmarshallPositionRotationMessage(message, out avatarId, out x, out z, out r, out m);
        RemoteAvatarScript remoteAvatarScript = _remoteAvatar.GetComponent <RemoteAvatarScript>();

        remoteAvatarScript.targetPosition      = new Vector3(x, 0f, z);
        remoteAvatarScript.targetRotation      = Quaternion.Euler(0f, r, 0f);
        remoteAvatarScript.targetMovementState = m;
        //--------------------------------
    }
    /// <summary>
    /// Following receipt of a position/rotation message from the server, update the position
    /// of the remote avatar. Unmarshall the message (to obtain the position, rotation and
    /// animation information) and then perform the necessary updates to the remote avatar.
    /// </summary>
    /// <param name="message">Message.</param>
    void UpdateRemoteAvatar(byte[] message)
    {
        Debug.Log("Length of remote avatar marshalled message: " + message.Length);
        byte  avatarId;
        float x, z, r;
        byte  m;

        // ... Attempt
        Messages.UnmarshallPositionRotationMessage(message, out avatarId, out x, out z, out r, out m);
        Debug.Log("Umarshalled data: " + avatarId + ", x: " + x + ", z: " + z + ", r: " + r + ", m: " + m);

        RemoteAvatarScript ras = _remoteAvatar.GetComponent <RemoteAvatarScript>();

        ras.targetPosition      = new Vector3(x, 2.25f, z);
        ras.targetRotation      = Quaternion.Euler(0f, r, 0f);
        ras.targetMovementState = m;
    }