Ejemplo n.º 1
0
        public void HandleCameraView()
        {
            if (pluginSettings.ready)
            {
                // Call the camera's behavior.
                currentCamera.ApplyBehavior(ref cameraPositionTarget, ref cameraLookAtTarget, player, isCameraStatic);
                isCameraStatic = currentCamera.staticCamera;


                if (currentAvatar != null)
                {
                    if (pluginSettings.removeAvatarInsteadOfHead)
                    {
                        currentAvatar.avatarSettings.showAvatar.Value = !currentCamera.removeHead;
                    }
                    else
                    {
                        currentAvatar.avatarSettings.showAvatarHead.Value = !currentCamera.removeHead;
                    }
                    timerHelper.ResetRemoveAvatarTimer();
                }

                cameraPosition = Vector3.SmoothDamp(cameraPosition, cameraPositionTarget, ref cameraVelocity, currentCamera.GetBetweenTime());
                cameraLookAt   = Vector3.SmoothDamp(cameraLookAt, cameraLookAtTarget, ref cameraLookAtVelocity, currentCamera.GetBetweenTime());

                Vector3 lookDirection = cameraLookAt - cameraPosition;

                Quaternion rotation = currentCamera.GetRotation(lookDirection, player);

                cameraHelper.UpdateCameraPose(cameraPosition, rotation, currentCamera.GetFOV());
            }
        }
Ejemplo n.º 2
0
        /*
         *
         * Logic for Scope should only occur when
         */
        public override void ApplyBehavior(ref Vector3 cameraTarget, ref Vector3 lookAtTarget, LivPlayerEntity player, bool isCameraAlreadyPlaced)
        {
            Vector3 averageHandPosition = player.handAverage;
            Vector3 handDirection;

            if (pluginSettings.rightHandDominant)
            {
                handDirection = (player.leftHand.position - player.rightHand.position).normalized;
            }
            else
            {
                handDirection = (player.rightHand.position - player.leftHand.position).normalized;
            }

            // If Hands close enough, and aligned, then do the thing, if not then
            float handDistance               = Vector3.Distance(player.rightHand.position, player.leftHand.position);
            bool  isWithinTwoHandedUse       = handDistance > pluginSettings.cameraGunMinTwoHandedDistance && handDistance < pluginSettings.cameraGunMaxTwoHandedDistance;
            bool  isHeadWithinAimingDistance = Vector3.Distance(averageHandPosition, player.head.position) < pluginSettings.cameraGunHeadDistanceTrigger;
            bool  isAimingTwoHandedForward   = Mathf.Rad2Deg * PluginUtility.GetConeAngle(player.head.position, averageHandPosition + handDirection * 4f, player.head.right) <
                                               pluginSettings.cameraGunHeadAlignAngleTrigger;

            if (!pluginSettings.disableGunCamera && Mathf.Abs(player.headRRadialDelta.x) < pluginSettings.controlMovementThreshold / 2 &&
                isWithinTwoHandedUse && isHeadWithinAimingDistance && isAimingTwoHandedForward)
            {
                ironSightsEnabled = true;
                // Should have a smooth transition between Iron Sights and non iron sights.
                sightsCamera.ApplyBehavior(ref cameraTarget, ref lookAtTarget, player, isCameraAlreadyPlaced);
                blend += (pluginSettings.cameraGunSmoothing / 2) * Time.deltaTime;
            }
            else
            {
                ironSightsEnabled = false;
                cameraTarget      = player.head.TransformPoint(offset);
                lookAtTarget      = player.head.TransformPoint(lookAtOffset);


                blend -= 1 / (pluginSettings.cameraGunSmoothing / 2) * Time.deltaTime;
            }

            blend = Mathf.Clamp(blend, 0, 1.0f);
        }
Ejemplo n.º 3
0
        public void SnapCamera(ActionCamera camera, bool revert = false)
        {
            PluginLog.Log("ActionCameraDirector", "SNAP ");
            camera.ApplyBehavior(ref cameraPositionTarget, ref cameraLookAtTarget, player, isCameraStatic);

            if (revert)
            {
                cameraLookAtVelocity = cameraLastLookAtVelocity;
                cameraVelocity       = cameraLastVelocity;
            }
            else
            {
                cameraLastLookAtVelocity = cameraLookAt;
                cameraLastVelocity       = cameraVelocity;
                cameraLookAtVelocity     = Vector3.zero;
                cameraVelocity           = Vector3.zero;
            }

            cameraPosition = cameraPositionTarget;
            cameraLookAt   = cameraLookAtTarget;
        }