diff --git a/Assets/Scripts/Editor/RopeEditor.cs b/Assets/Scripts/Editor/RopeEditor.cs index 528f4239d..595601183 100644 --- a/Assets/Scripts/Editor/RopeEditor.cs +++ b/Assets/Scripts/Editor/RopeEditor.cs @@ -19,7 +19,7 @@ public class RopeFishLineEditor : Editor if (GUILayout.Button("打印总长度")) { - Debug.Log($"总长度={_target.GetCurrentLength()} 目标长度={_target.GetTargetLength()}"); + Debug.Log($"总长度={_target.GetCurrentLength()} 目标长度={_target.GetTargetLength()} smoot={_target.GetLengthSmoothVel()} relLen={_target.GetLengthByPoints()}"); } // serializedObject.Update(); // EditorGUILayout.PropertyField(lookAtPoint); diff --git a/Assets/Scripts/Fishing/Rope/Rope.cs b/Assets/Scripts/Fishing/Rope/Rope.cs index d7a2f5bd6..61611aee7 100644 --- a/Assets/Scripts/Fishing/Rope/Rope.cs +++ b/Assets/Scripts/Fishing/Rope/Rope.cs @@ -235,6 +235,27 @@ public class Rope : MonoBehaviour public void SetTargetLength(float lengthMeters) => _targetLength = Mathf.Max(0f, lengthMeters); public float GetCurrentLength() => _currentLength; public float GetTargetLength() => _targetLength; + + public float GetLengthSmoothVel() => _lengthSmoothVel; + + public float GetLengthByPoints() + { + if (_rPoints == null || _lineRenderer == null) return 0f; + + int count = _lineRenderer.positionCount; + if (count < 2) return 0f; + + float totalLength = 0f; + for (int i = 1; i < count; i++) + { + Vector3 a = _rPoints[i - 1]; + Vector3 b = _rPoints[i]; + totalLength += Vector3.Distance(a, b); + } + + return totalLength; + } + private void FixedUpdate() { diff --git a/Assets/Scripts/Fishing/Tackle/FLine.cs b/Assets/Scripts/Fishing/Tackle/FLine.cs index de3d18cb3..0820bea41 100644 --- a/Assets/Scripts/Fishing/Tackle/FLine.cs +++ b/Assets/Scripts/Fishing/Tackle/FLine.cs @@ -121,7 +121,7 @@ namespace NBF public void SetObiRopeStretch(float value) { Log.Error($"SetObiRopeStretch={value}"); - fishingRope.SetTargetLength(value - 0.2f); + fishingRope.SetTargetLength(value); } } } \ No newline at end of file