Esempio n. 1
0
    public void SetPlayerBody(PlayerBody newPlayerBody)
    {
        AbandonPlayerBody();
        playerBody = newPlayerBody;
        if (playerBody != null)
        {
            playerBody.StartControlling(this);
            bodyParent = playerBody.GetAvatarTransform();
            navigationControls.UpdateRotationValues(playerBody.GetHeadTransform().rotation);
            childTransform.SetParent(playerBody.GetHeadTransform());
            SetAvatarTransform(playerBody.transform);
        }
        else
        {
            bodyParent = null;
            navigationControls.UpdateRotationValues(Quaternion.identity);
            childTransform.SetParent(null);
            SetAvatarTransform(null);
        }

        childTransform.localPosition = Vector3.zero;
        childTransform.localRotation = Quaternion.identity;
    }