animancer
This commit is contained in:
@@ -31,7 +31,6 @@ namespace RebootReality.jelycho.Player {
|
||||
[SerializeField] float m_RunCameraBobbing = 0.5f;
|
||||
[SerializeField] float m_IdleCameraBobbing = 0.0f;
|
||||
[SerializeField] float m_CameraBobbingTransitionSpeed = 5.0f;
|
||||
[SerializeField] float m_TurnTransitionSpeed = 5.0f;
|
||||
|
||||
float m_TargetCameraBobbing = 0.0f;
|
||||
float m_CurrentCameraBobbing = 0.0f;
|
||||
@@ -49,7 +48,6 @@ namespace RebootReality.jelycho.Player {
|
||||
[SerializeField] float m_CharacterRotateFastSpeed = 720.0f;
|
||||
|
||||
float m_CharacterTurnVelocity = 0.0f;
|
||||
float m_CharacterTurnVelocitySmooth = 0.0f;
|
||||
|
||||
[Header("Animations")]
|
||||
[SerializeField] int m_HandsLayerIndex;
|
||||
@@ -847,7 +845,9 @@ namespace RebootReality.jelycho.Player {
|
||||
float3 targetCharacterForward = math.normalize(LookDirection.With(y: 0.0f));
|
||||
float3 currentCharacterForward = math.normalize(m_CharacterForwardTransform.forward.With(y: 0.0f));
|
||||
|
||||
float angleDeg = Mathf.DeltaAngle(m_Camera.Yaw, m_Locomotion.YawRotation);
|
||||
// float angleDeg = Mathf.DeltaAngle(m_Camera.Yaw, m_Locomotion.YawRotation);
|
||||
float angleRad = math.acos(math.clamp(math.dot(targetCharacterForward, currentCharacterForward) / (math.length(targetCharacterForward) * math.length(currentCharacterForward)), -1f, 1f));
|
||||
float angleDeg = math.degrees(angleRad);
|
||||
|
||||
bool rotateCharacter = false;
|
||||
float rotateCharacterSpeed = m_CharacterRotateSpeed;
|
||||
@@ -870,13 +870,14 @@ namespace RebootReality.jelycho.Player {
|
||||
|
||||
if (rotateCharacter) {
|
||||
m_CharacterTurnVelocity = rotateCharacterSpeed * dt;
|
||||
m_CharacterTurnVelocitySmooth = m_CharacterTurnVelocity;
|
||||
|
||||
|
||||
var newForward = Vector3.RotateTowards(currentCharacterForward,
|
||||
targetCharacterForward,
|
||||
math.radians(m_CharacterTurnVelocity),
|
||||
0.0f);
|
||||
m_CharacterForwardTransform.forward = newForward;
|
||||
} else {
|
||||
m_CharacterTurnVelocity = 0.0f;
|
||||
}
|
||||
|
||||
// Aim Target adjustment
|
||||
@@ -991,20 +992,16 @@ namespace RebootReality.jelycho.Player {
|
||||
if (math.abs(forwardNormalized) > 0.01f ||
|
||||
math.abs(rightNormalized) > 0.01f ||
|
||||
!m_Locomotion.IsGrounded) {
|
||||
m_CharacterTurnVelocitySmooth = 0.0f;
|
||||
m_CharacterTurnVelocity = 0.0f;
|
||||
}
|
||||
|
||||
var locomotionParams = new PlayerLocomotionAnimatorParams {
|
||||
IsGrounded = m_Locomotion.IsGrounded,
|
||||
VelocityForwardNormalized = forwardNormalized,
|
||||
VelocityRightNormalized = rightNormalized,
|
||||
TurnVelocity = m_CharacterTurnVelocitySmooth
|
||||
TurnVelocity = math.clamp(m_CharacterTurnVelocity, -1, 1)
|
||||
};
|
||||
m_PlayerAnimator.SetLocomotionParams(locomotionParams);
|
||||
|
||||
m_CharacterTurnVelocitySmooth = Mathf.MoveTowards(m_CharacterTurnVelocitySmooth,
|
||||
0.0f,
|
||||
m_TurnTransitionSpeed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user