增加线测试代码
This commit is contained in:
@@ -19,7 +19,7 @@ public class RopeFishLineEditor : Editor
|
|||||||
|
|
||||||
if (GUILayout.Button("打印总长度"))
|
if (GUILayout.Button("打印总长度"))
|
||||||
{
|
{
|
||||||
Debug.Log($"总长度={_target.GetCurrentLength()} 目标长度={_target.GetTargetLength()}");
|
Debug.Log($"总长度={_target.GetCurrentLength()} 目标长度={_target.GetTargetLength()} smoot={_target.GetLengthSmoothVel()} relLen={_target.GetLengthByPoints()}");
|
||||||
}
|
}
|
||||||
// serializedObject.Update();
|
// serializedObject.Update();
|
||||||
// EditorGUILayout.PropertyField(lookAtPoint);
|
// EditorGUILayout.PropertyField(lookAtPoint);
|
||||||
|
|||||||
@@ -235,6 +235,27 @@ public class Rope : MonoBehaviour
|
|||||||
public void SetTargetLength(float lengthMeters) => _targetLength = Mathf.Max(0f, lengthMeters);
|
public void SetTargetLength(float lengthMeters) => _targetLength = Mathf.Max(0f, lengthMeters);
|
||||||
public float GetCurrentLength() => _currentLength;
|
public float GetCurrentLength() => _currentLength;
|
||||||
public float GetTargetLength() => _targetLength;
|
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()
|
private void FixedUpdate()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ namespace NBF
|
|||||||
public void SetObiRopeStretch(float value)
|
public void SetObiRopeStretch(float value)
|
||||||
{
|
{
|
||||||
Log.Error($"SetObiRopeStretch={value}");
|
Log.Error($"SetObiRopeStretch={value}");
|
||||||
fishingRope.SetTargetLength(value - 0.2f);
|
fishingRope.SetTargetLength(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user