修改绳的逻辑

This commit is contained in:
2026-04-16 10:38:26 +08:00
parent a0fa4e6e9c
commit 9681d7526f
4 changed files with 23 additions and 2 deletions

View File

@@ -488,10 +488,18 @@ PrefabInstance:
propertyPath: startAnchor
value:
objectReference: {fileID: 1005026351}
- target: {fileID: 114581403422500557, guid: ea6901d8aa7c41d41987d8ca92b02f6d, type: 3}
propertyPath: constrainToWaterSurface
value: 0
objectReference: {fileID: 0}
- target: {fileID: 420085638995403055, guid: ea6901d8aa7c41d41987d8ca92b02f6d, type: 3}
propertyPath: Rope
value:
objectReference: {fileID: 410242110}
- target: {fileID: 420085638995403055, guid: ea6901d8aa7c41d41987d8ca92b02f6d, type: 3}
propertyPath: _rope
value:
objectReference: {fileID: 410242110}
- target: {fileID: 484878994603287356, guid: ea6901d8aa7c41d41987d8ca92b02f6d, type: 3}
propertyPath: m_Parameters.widthCurve.m_Curve.Array.data[0].value
value: 0.001
@@ -508,6 +516,10 @@ PrefabInstance:
propertyPath: Rope
value:
objectReference: {fileID: 1092033884}
- target: {fileID: 3199098293373602285, guid: ea6901d8aa7c41d41987d8ca92b02f6d, type: 3}
propertyPath: _rope
value:
objectReference: {fileID: 1092033884}
- target: {fileID: 7888891488031969805, guid: ea6901d8aa7c41d41987d8ca92b02f6d, type: 3}
propertyPath: anchorTransform
value:
@@ -551,7 +563,7 @@ GameObject:
- component: {fileID: 1181671548}
- component: {fileID: 1181671547}
- component: {fileID: 1181671546}
m_Layer: 0
m_Layer: 3
m_Name: Terrain
m_TagString: Untagged
m_Icon: {fileID: 0}

View File

@@ -44,6 +44,8 @@ namespace NBF
set => nodeType = value;
}
public float Lenght => _joint != null ? _joint.linearLimit.limit : 0f;
public Rigidbody Body => body;
public MonoBehaviour Interaction => interaction;
@@ -91,6 +93,12 @@ namespace NBF
public void SetLenght(float lenght)
{
if (!_joint) return;
if (!Mathf.Approximately(lenght, _joint.linearLimit.limit))
{
_joint.linearLimit = new SoftJointLimit() { limit = lenght };
_rope.SetTargetLength(lenght - 0.1f);
}
}
#endregion

View File

@@ -108,7 +108,7 @@ namespace NBF
public void SetLenght(float length, int index = 0)
{
ConfigureStartNode();
var node = logicalNodes[index];
var node = logicalNodes[index + 1];
if (node != null)
{
node.SetLenght(length);

View File

@@ -37,6 +37,7 @@ namespace NBF
targetFirstSegmentLength =
Mathf.Clamp(initialFirstSegmentLength, minFirstSegmentLength, maxFirstSegmentLength);
solver.SetLenght(targetFirstSegmentLength);
solver.SetLenght(0.5f, 1);
// solver.BuildLine();
solver.OnLineBreakRequested += OnLineBreakRequested;