Player run rotation

This commit is contained in:
2026-06-08 17:08:19 +02:00
parent 72cba96dcb
commit 1e9e4ace81
2 changed files with 29 additions and 913 deletions

File diff suppressed because one or more lines are too long

View File

@@ -488,19 +488,6 @@ public class Player : MonoBehaviour
_state.Velocity.x = Mathf.Lerp(_state.Velocity.x, moveInput.x, velovityTime); _state.Velocity.x = Mathf.Lerp(_state.Velocity.x, moveInput.x, velovityTime);
_state.Velocity.z = Mathf.Lerp(_state.Velocity.z, moveInput.z, velovityTime); _state.Velocity.z = Mathf.Lerp(_state.Velocity.z, moveInput.z, velovityTime);
// Rotate Player
if (moveInput.sqrMagnitude > .001f)
{
Quaternion targetRot = Quaternion.LookRotation(moveInput);
if (_state.IsStickedToWall)
targetRot = Quaternion.LookRotation(_wallDirection);
float t = _settings.RotationSpeed * deltaTime;
Vector3 euler = Quaternion.Slerp(transform.rotation, targetRot, t).eulerAngles;
transform.rotation = Quaternion.Euler(0, euler.y, 0);
}
} }
private void SetJump() private void SetJump()
@@ -532,6 +519,25 @@ public class Player : MonoBehaviour
} }
_references.Controller.Move(motion * deltaTime); _references.Controller.Move(motion * deltaTime);
// Rotate Player
if (_state.HorizontalVelocity.sqrMagnitude > .001f)
{
Vector3 velocity = _state.HorizontalVelocity;
if (_state.Running > 0)
{
velocity = Vector3.Lerp(velocity, Vector3.down, _state.Running * .4f).normalized;
}
Quaternion targetRot = Quaternion.LookRotation(velocity, Vector3.up);
if (_state.IsStickedToWall)
targetRot = Quaternion.LookRotation(_wallDirection);
float t = _settings.RotationSpeed * deltaTime;
targetRot = Quaternion.Slerp(transform.rotation, targetRot, t);
transform.rotation = targetRot;
}
} }
private void SetState() private void SetState()