Player run rotation
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -488,19 +488,6 @@ public class Player : MonoBehaviour
|
||||
|
||||
_state.Velocity.x = Mathf.Lerp(_state.Velocity.x, moveInput.x, 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()
|
||||
@@ -532,6 +519,25 @@ public class Player : MonoBehaviour
|
||||
}
|
||||
|
||||
_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()
|
||||
|
||||
Reference in New Issue
Block a user