void Update()
        {
            try
            {
                if (avatar != null && !forcePlayerInfo)
                {
                    if (Client.Instance.Tickrate < (1f / Time.smoothDeltaTime))
                    {
                        interpolationProgress += Time.deltaTime * Client.Instance.Tickrate;
                    }
                    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)
            {
                Misc.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 (_camera != null)
                {
                    if (Config.Instance.SpectatorMode)
                    {
                        playerNameText.rectTransform.rotation = Quaternion.LookRotation(playerNameText.rectTransform.position - _camera.transform.position);
                    }
                }
                else
                {
                    playerNameText.rectTransform.rotation = Quaternion.LookRotation(playerNameText.rectTransform.position - InGameOnlineController.GetXRNodeWorldPosRot(XRNode.Head).Position);
                }
            }
            catch (Exception e)
            {
                Misc.Logger.Warning("Unable to rotate text to the camera! Exception: " + e);
            }
        }
示例#2
0
        void Update()
        {
            try
            {
                if (playerNameText != null)
                {
                    if (IllusionInjector.PluginManager.Plugins.Any(x => x.Name == "CameraPlus") && _camera == null)
                    {
                        _camera = FindObjectsOfType <Camera>().FirstOrDefault(x => x.name.StartsWith("CamPlus_"));
                    }

                    if (_camera != null)
                    {
                        if (Config.Instance.SpectatorMode)
                        {
                            playerNameText.rectTransform.rotation    = Quaternion.LookRotation(playerNameText.rectTransform.position - _camera.transform.position);
                            playerSpeakerIcon.rectTransform.rotation = Quaternion.LookRotation(playerSpeakerIcon.rectTransform.position - _camera.transform.position);
                        }
                    }
                    else
                    {
                        playerNameText.rectTransform.rotation    = Quaternion.LookRotation(playerNameText.rectTransform.position - InGameOnlineController.GetXRNodeWorldPosRot(XRNode.Head).Position);
                        playerSpeakerIcon.rectTransform.rotation = Quaternion.LookRotation(playerSpeakerIcon.rectTransform.position - InGameOnlineController.GetXRNodeWorldPosRot(XRNode.Head).Position);
                    }
                }
            }
            catch (Exception e)
            {
                Misc.Logger.Warning($"Unable to rotate text to the camera! Exception: {e}");
            }
        }
        void Update()
        {
            try
            {
                if (playerNameText != null)
                {
                    if (IPA.Loader.PluginManager.AllPlugins.Select(x => x.Metadata.Name) //BSIPA Plugins
                        .Concat(IPA.Loader.PluginManager.Plugins.Select(x => x.Name))    //Old IPA Plugins
                        .Any(x => x == "CameraPlus") && (_camera == null || !_camera.isActiveAndEnabled))
                    {
                        _camera = FindObjectsOfType <Camera>().FirstOrDefault(x => (x.name.StartsWith("CamPlus_") || x.name.Contains("cameraplus")) && x.isActiveAndEnabled);
                    }

                    if (_camera != null)
                    {
                        if (Config.Instance.SpectatorMode)
                        {
                            playerNameText.rectTransform.rotation    = Quaternion.LookRotation(playerNameText.rectTransform.position - _camera.transform.position);
                            playerSpeakerIcon.rectTransform.rotation = Quaternion.LookRotation(playerSpeakerIcon.rectTransform.position - _camera.transform.position);
                        }
                    }
                    else
                    {
                        playerNameText.rectTransform.rotation    = Quaternion.LookRotation(playerNameText.rectTransform.position - InGameOnlineController.GetXRNodeWorldPosRot(XRNode.Head).Position);
                        playerSpeakerIcon.rectTransform.rotation = Quaternion.LookRotation(playerSpeakerIcon.rectTransform.position - InGameOnlineController.GetXRNodeWorldPosRot(XRNode.Head).Position);
                    }
                }
            }
            catch (Exception e)
            {
                Plugin.log.Warn($"Unable to rotate text to the camera! Exception: {e}");
            }
        }