From 06146e3d0797cce893d8b1ce4fb61d3ef32b09df Mon Sep 17 00:00:00 2001 From: BobSong <605277374@qq.com> Date: Thu, 5 Mar 2026 23:54:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BA=BF=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Editor/RopeEditor.cs | 2 +- Assets/Scripts/Fishing/Rope/Rope.cs | 21 +++++++++++++++++++++ Assets/Scripts/Fishing/Tackle/FLine.cs | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) 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