Exemplo n.º 1
0
        public static CharacterPosition GetCharacterInfo()
        {
            HandOffset leftOffs = GetLeftHandOffs();

            return(new CharacterPosition

            {
                headPos = WorldController.GetXRNodeWorldPosRot(XRNode.Head).Position,
                headRot = WorldController.GetXRNodeWorldPosRot(XRNode.Head).Rotation,
                leftHandPos = WorldController.GetXRNodeWorldPosRot(XRNode.LeftHand).Position + leftOffs.LeftHandPos,
                leftHandRot = WorldController.GetXRNodeWorldPosRot(XRNode.LeftHand).Rotation *leftOffs.LeftHandRot,

                rightHandPos = WorldController.GetXRNodeWorldPosRot(XRNode.RightHand).Position,
                rightHandRot = WorldController.GetXRNodeWorldPosRot(XRNode.RightHand).Rotation
            });
        }
Exemplo n.º 2
0
        public void UpdatePlayerPacket()
        {
            _playerInfo.avatarHash = ModelSaberAPI.cachedAvatars.FirstOrDefault(x => x.Value == CustomAvatar.Plugin.Instance.PlayerAvatarManager.GetCurrentAvatar()).Key;
            if (_playerInfo.avatarHash == null)
            {
                _playerInfo.avatarHash = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
            }

            _playerInfo.playerName = SteamAPI.GetUserName();
            _playerInfo.playerId   = SteamAPI.GetUserID();

            WorldController.CharacterPosition pos = WorldController.GetCharacterInfo();
            _playerInfo.headPos      = pos.headPos;
            _playerInfo.headRot      = pos.headRot;
            _playerInfo.leftHandPos  = pos.leftHandPos;
            _playerInfo.leftHandRot  = pos.leftHandRot;
            _playerInfo.rightHandPos = pos.rightHandPos;
            _playerInfo.rightHandRot = pos.rightHandRot;
        }
Exemplo n.º 3
0
        void Update()
        {
            try
            {
                if (avatar != null && !forcePlayerPacket)
                {
                    if (GameController.TPS < (1f / Time.smoothDeltaTime))
                    {
                        interpolationProgress += Time.deltaTime * GameController.TPS;
                    }
                    else
                    {
                        interpolationProgress = 1f;
                    }
                    if (interpolationProgress > 1f)
                    {
                        interpolationProgress = 1f;
                    }

                    interpHeadPos      = Vector3.Lerp(lastHeadPos, targetHeadPos, interpolationProgress);
                    interpLeftHandPos  = Vector3.Lerp(lastLeftHandPos, targetLeftHandPos, interpolationProgress);
                    interpRightHandPos = Vector3.Lerp(lastRightHandPos, targetRightHandPos, interpolationProgress);

                    interpHeadRot      = Quaternion.Lerp(lastHeadRot, targetHeadRot, interpolationProgress);
                    interpLeftHandRot  = Quaternion.Lerp(lastLeftHandRot, targetLeftHandRot, interpolationProgress);
                    interpRightHandRot = Quaternion.Lerp(lastRightHandRot, targetRightHandRot, interpolationProgress);

                    transform.position = interpHeadPos;
                }
            }
            catch (Exception e)
            {
                Logger.Error("Unable to lerp avatar position! Exception: " + e);
            }

            try
            {
                if (IllusionInjector.PluginManager.Plugins.Any(x => x.Name == "CameraPlus") && _camera == null)
                {
                    _camera = FindObjectsOfType <Camera>().FirstOrDefault(x => x.name == "Camera Plus");
                }
                if (playerNameText)
                {
                    playerNameText.rectTransform.rotation = Quaternion.LookRotation(playerNameText.rectTransform.position - WorldController.GetXRNodeWorldPosRot(XRNode.Head).Position);
                }
            }
            catch (Exception e)
            {
                Logger.Warning("Unable to rotate text to the camera! Exception: " + e);
            }
        }