예제 #1
0
        private void UpdateFollowCameraData(float deltaTime, FollowCameraNode cameraNode, CameraTargetNode targetNode, TankNode tank, MouseControlStateHolderComponent mouseControlStateHolder)
        {
            GameObject targetObject = targetNode.cameraTarget.TargetObject;

            if (targetObject != null)
            {
                CameraTransformDataComponent cameraTransformData = cameraNode.cameraTransformData;
                Transform             target         = targetObject.transform;
                FollowCameraComponent followCamera   = cameraNode.followCamera;
                BezierPosition        bezierPosition = cameraNode.bezierPosition.BezierPosition;
                CameraData            cameraData     = followCamera.cameraData;
                this.UpdateBezierPosition(bezierPosition, followCamera.verticalCameraSpeed, deltaTime, targetNode.weaponRotationControl.MouseRotationCumulativeVerticalAngle, mouseControlStateHolder.MouseVerticalInverted);
                targetNode.weaponRotationControl.MouseRotationCumulativeVerticalAngle = 0f;
                float mouseRotationCumulativeHorizontalAngle = targetNode.weaponRotationControl.MouseRotationCumulativeHorizontalAngle;
                if (Mathf.Abs(MathUtil.ClampAngle180(Vector3.Angle(target.up, Vector3.up))) > 90f)
                {
                    mouseRotationCumulativeHorizontalAngle *= -1f;
                }
                bool mouse = targetNode.weaponRotationControl.MouseRotationCumulativeHorizontalAngle != 0f;
                CameraOffsetConfigComponent cameraOffsetConfig = cameraNode.cameraOffsetConfig;
                Vector3 cameraOffset     = new Vector3(cameraOffsetConfig.XOffset, cameraOffsetConfig.YOffset, cameraOffsetConfig.ZOffset);
                Vector3 cameraCalculated = CameraPositionCalculator.CalculateCameraPosition(target, tank.baseRenderer, tank.tankColliders.BoundsCollider.bounds.center, bezierPosition, cameraData, cameraOffset, mouseRotationCumulativeHorizontalAngle);
                Vector3 rotation         = cameraTransformData.Data.Rotation.eulerAngles * 0.01745329f;
                CameraPositionCalculator.CalculatePitchMovement(ref rotation, bezierPosition, deltaTime, cameraData, mouse);
                CameraPositionCalculator.CalculateYawMovement((Vector3)(Quaternion.Euler(new Vector3(0f, mouseRotationCumulativeHorizontalAngle, 0f)) * target.forward), ref rotation, deltaTime, cameraData, mouse);
                CameraPositionCalculator.SmoothReturnRoll(ref rotation, followCamera.rollReturnSpeedDegPerSec, deltaTime);
                TransformData data4 = new TransformData {
                    Position = CameraPositionCalculator.CalculateLinearMovement(deltaTime, cameraCalculated, cameraTransformData.Data.Position, cameraData, target, mouse),
                    Rotation = Quaternion.Euler(rotation * 57.29578f)
                };
                cameraTransformData.Data = data4;
            }
        }
예제 #2
0
        public void Follow(CameraFollowEvent e, CameraTargetNode cameraTargetNode, [JoinByTank] TankNode tank, [JoinAll] CameraNode cameraNode, [JoinAll] Optional <SingleNode <FollowCameraComponent> > followCameraOptionalNode)
        {
            CameraTransformDataComponent cameraTransformData = cameraNode.cameraTransformData;
            CameraOffsetConfigComponent  cameraOffsetConfig  = cameraNode.cameraOffsetConfig;
            Vector3        cameraOffset   = new Vector3(cameraOffsetConfig.XOffset, cameraOffsetConfig.YOffset, cameraOffsetConfig.ZOffset);
            BezierPosition bezierPosition = cameraNode.bezierPosition.BezierPosition;

            cameraTransformData.Data = CameraPositionCalculator.GetTargetFollowCameraTransformData(cameraTargetNode.cameraTarget.TargetObject.transform, tank.baseRenderer, tank.tankColliders.BoundsCollider.bounds.center, bezierPosition, cameraOffset);
            cameraNode.cameraRootTransform.Root.SetPositionSafe(cameraTransformData.Data.Position);
            cameraNode.cameraRootTransform.Root.SetRotationSafe(cameraTransformData.Data.Rotation);
        }
예제 #3
0
        private void InitFollowCamera(TransitionCameraNode cameraNode, WeaponNode weapon, TankNode tank, float flyTimeSec, float flyHeight)
        {
            TransitionCameraComponent transitionCamera = cameraNode.transitionCamera;
            Transform      target         = weapon.cameraTarget.TargetObject.transform;
            BezierPosition bezierPosition = cameraNode.bezierPosition.BezierPosition;
            CameraOffsetConfigComponent cameraOffsetConfig = cameraNode.cameraOffsetConfig;
            Vector3    cameraOffset = new Vector3(cameraOffsetConfig.XOffset, cameraOffsetConfig.YOffset, cameraOffsetConfig.ZOffset);
            CameraData cameraData   = new CameraData();
            Vector3    position     = CameraPositionCalculator.CalculateCameraPosition(target, tank.baseRenderer, tank.tankColliders.BoundsCollider.bounds.center, bezierPosition, cameraData, cameraOffset, 0f);
            Vector3    zero         = Vector3.zero;

            zero.x = -CameraPositionCalculator.GetPitchAngle(cameraData, bezierPosition) * 57.29578f;
            zero.y = target.transform.rotation.eulerAngles.y;
            InitCamera(cameraNode, position, zero, flyTimeSec, flyHeight);
        }