提交修改

This commit is contained in:
2026-04-17 00:21:55 +08:00
parent c55d38b3a6
commit d7028a5664
4 changed files with 137 additions and 12 deletions

View File

@@ -44,7 +44,17 @@ namespace NBF
set => nodeType = value;
}
public float Lenght => _joint != null ? _joint.linearLimit.limit : 0f;
public float Lenght { get; private set; }
/// <summary>
/// 真实实际长度
/// </summary>
public float RealLength { get; private set; }
/// <summary>
/// 当前逻辑链总长度超出配置总长度的部分,小于等于零时记为 0。
/// </summary>
public float StretchLength { get; private set; }
public Rigidbody Body => body;
@@ -77,6 +87,7 @@ namespace NBF
{
EnsureFeatureCache();
UpdateMotionControl(Time.fixedDeltaTime);
UpdateLenght();
}
private void OnValidate()
@@ -87,6 +98,28 @@ namespace NBF
}
segmentLengthToNext = Mathf.Max(0f, segmentLengthToNext);
}
private void UpdateLenght()
{
//更新长度
Lenght = 0;
RealLength = 0;
StretchLength = 0;
if (_joint)
{
Lenght = _joint.linearLimit.limit;
if (_joint && _joint.connectedBody)
{
RealLength = Vector3.Distance(transform.position, _joint.connectedBody.transform.position);
}
}
if (RealLength > Lenght)
{
StretchLength = RealLength - Lenght;
}
}
#region Line