diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantPlayerDataSo.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantPlayerDataSo.cs index 821f72879..b5e4f73fd 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantPlayerDataSo.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantPlayerDataSo.cs @@ -24,6 +24,18 @@ public class RestaurantPlayerDataSo : ScriptableObject [Range(0f, 3f), Tooltip("슬라이딩 보정 제곱\n낮을수록 슬라이딩이 잘 됨")] public float SlidingThreshold = 0.5f; + public float VelocityMinThreshold = 0.01f; + public float BoxCastExtentScale = 0.95f; + public float MinSlideFactorThreshold = 0.05f; + + // 디버그 + public int InputLineSortingOrder = 10; + public int VelocityLineSortingOrder = 9; + public float InputLineWidth = 0.1f; + public float VelocityLineWidth = 0.2f; + public float InputLineLength = 1.5f; + public float VelocityLineScale = 0.5f; + public string WalkingSfxName; public string DashSfxName; diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantPlayerMovement.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantPlayerMovement.cs index 12cd2ff23..8187f8d0f 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantPlayerMovement.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantPlayerMovement.cs @@ -27,6 +27,10 @@ public class RestaurantPlayerMovement : RestaurantCharacterMovement public Action OnMoving; public Action OnDashing; + private const string InputDebugLineRenderer = "DebugLine_Input"; + private const string VelocityDebugLineRenderer = "DebugLine_Velocity"; + private const string SpriteDefaultShader = "Sprites/Default"; + private void Awake() { _rigidbody = GetComponent(); @@ -75,17 +79,18 @@ private void OnDestroy() _playerDataSo.DashActionReference.action.performed -= OnDash; } } - + +#if UNITY_EDITOR private void DrawLineDebug() { Vector3 origin = transform.position; if (_inputDirection != Vector3.zero) { - Vector3 target = origin + _inputDirection.normalized * 1.5f; + Vector3 target = origin + _inputDirection.normalized * _playerDataSo.InputLineLength; if (_inputLineRenderer == null) { - _inputLineRenderer = CreateOrGetDebugLineRenderer("DebugLine_Input", 10, 0.1f, Color.blue); + _inputLineRenderer = CreateOrGetDebugLineRenderer(InputDebugLineRenderer, _playerDataSo.InputLineSortingOrder, _playerDataSo.InputLineWidth, Color.blue); } UpdateLineRenderer(_inputLineRenderer, origin, target); @@ -97,13 +102,13 @@ private void DrawLineDebug() } float speed = _currentVelocity.magnitude; - if (speed > 0.01f) + if (speed > _playerDataSo.VelocityMinThreshold) { - Vector3 target = origin + _currentVelocity.normalized * (speed * 0.5f); + Vector3 target = origin + _currentVelocity.normalized * (speed * _playerDataSo.VelocityLineScale); if (_velocityLineRenderer == null) { - _velocityLineRenderer = CreateOrGetDebugLineRenderer("DebugLine_Velocity", 9, 0.2f, Color.red); + _velocityLineRenderer = CreateOrGetDebugLineRenderer(VelocityDebugLineRenderer, _playerDataSo.VelocityLineSortingOrder, _playerDataSo.VelocityLineWidth, Color.red); } UpdateLineRenderer(_velocityLineRenderer, origin, target); @@ -134,7 +139,7 @@ private LineRenderer CreateOrGetDebugLineRenderer(string name, int sortingIndex, var lineRenderer = newGameObject.AddComponent(); lineRenderer.positionCount = 2; - lineRenderer.material = new Material(Shader.Find("Sprites/Default")); // URP 호환 + lineRenderer.material = new Material(Shader.Find(SpriteDefaultShader)); // URP 호환 lineRenderer.sortingOrder = sortingIndex; lineRenderer.startWidth = lineRenderer.endWidth = width; lineRenderer.startColor = lineRenderer.endColor = color; @@ -148,6 +153,7 @@ private void UpdateLineRenderer(LineRenderer lr, Vector3 start, Vector3 end) lr.SetPosition(0, start); lr.SetPosition(1, end); } +#endif public void SetCurrentDirection(Vector3 normalDirection) { @@ -198,14 +204,14 @@ private Vector3 GetSlideAdjustedDirection(Vector3 inputDirection) : _boxCollider.bounds.size.z; int layerMask = ~_playerDataSo.IgnoreSlidingLayerMask; - if (Physics.BoxCast(origin, halfExtents * 0.95f, inputDirection, out RaycastHit hit, rotation, distance, layerMask)) + if (Physics.BoxCast(origin, halfExtents * _playerDataSo.BoxCastExtentScale, inputDirection, out RaycastHit hit, rotation, distance, layerMask)) { Vector3 slide = Vector3.ProjectOnPlane(inputDirection, hit.normal).normalized; float dot = Vector3.Dot(inputDirection.normalized, hit.normal); float slideFactor = Mathf.Pow(1f - Mathf.Abs(dot), _playerDataSo.SlidingThreshold); - if (slideFactor < 0.05f) return Vector3.zero; + if (slideFactor < _playerDataSo.MinSlideFactorThreshold) return Vector3.zero; return slide * slideFactor; }