6 static private const float FREELOOK_FADE_SPEED = 4.0;
7 static private const float SLOPE_FACTOR = 1.0 / 90.0;
9 private float m_fFreelookBlend;
12 void CharacterCamera3rdPersonProne(CameraHandlerComponent pCameraHandler)
15 m_CameraOffsetMS =
"0.0 0.3 0.0";
16 m_CameraOffsetLS =
"0.0 0.2 0.0";
17 m_fShoulderWidth = 0.4;
21 override void OnUpdate(
float pDt, out ScriptedCameraItemResult pOutResult)
23 pOutResult.m_fFOV = m_fFOV;
24 float nextMSOffset = 0.2;
27 pOutResult.m_fFOV = m_fFOV + 2 * m_fBobScale;
29 HandleFreelook(pDt, pOutResult);
31 super.OnUpdate(pDt, pOutResult);
34 if (m_CharacterCameraHandler)
35 m_CharacterCameraHandler.AddShakeToToTransform(pOutResult.m_CameraTM, pOutResult.m_fFOV);
38 void HandleFreelook(
float pDt, inout ScriptedCameraItemResult pOutResult)
42 float tSlope = Math.Clamp(charaRot[1] * SLOPE_FACTOR, -1.0, 1.0);
43 float tSlopeUp = Math.Clamp(tSlope, 0.0, 1.0);
44 float tSlopeDn = Math.Clamp(tSlope, -1.0, 0.0) * -1.0;
48 m_fFreelookBlend = Math.Clamp(m_fFreelookBlend + FREELOOK_FADE_SPEED * pDt, 0.0, 1.0);
51 float downLimit = Math.Lerp(-60.0, 0.0, tSlopeDn);
52 float upLimit = Math.Lerp(89.9, 40.0, tSlope);
53 float leftLimit = Math.Lerp(-160.0, -40.0, tSlope);
54 float rightLimit = Math.Lerp(160.0, 80.0, tSlope);
55 m_CharacterHeadAimingComponent.SetLimitAnglesOverride(downLimit, upLimit, leftLimit, rightLimit);
59 m_fFreelookBlend = Math.Clamp(m_fFreelookBlend - FREELOOK_FADE_SPEED * pDt, 0.0, 1.0);
61 m_CharacterHeadAimingComponent.ResetLimitAnglesOverride();
64 vector lookAngles = m_CharacterHeadAimingComponent.GetLookAngles();
67 float yawMax = Math.Lerp(160.0, 40.0, Math.Max(0.0, tSlope));
68 lookAngles[0] = Math.Clamp(lookAngles[0], -yawMax, yawMax);
69 float tYaw = Math.InverseLerp(0.0, 160.0, Math.AbsFloat(lookAngles[0]));
71 float lookPitch = lookAngles[1] + charaRot[1];
72 lookAngles[1] = Math.Lerp(charaRot[1], -charaRot[1], tYaw);
74 pOutResult.m_vBacktraceDir = lookAngles.AnglesToVector();
77 const float pitchMin = Math.Lerp(-10.0, -charaRot[1], tYaw);
78 const float pitchMax = pitchMin + 20.0;
79 float alpha = Math.InverseLerp(pitchMin, pitchMax, Math.Clamp(lookPitch, pitchMin, pitchMax));
80 pOutResult.m_fUseBacktraceDir = m_fFreelookBlend * alpha;
83 float pitchReductionMultiplier = 1.0;
84 pitchReductionMultiplier = Math.Lerp(1.0, 0.7, tSlopeUp);
85 m_CharacterHeadAimingComponent.SetPitchLimitReductionMultiplier(Math.Lerp(1.0, pitchReductionMultiplier, m_fFreelookBlend));