fix(fix-system): 移除线缆拖拽的插孔自动吸附
This commit is contained in:
@@ -47,9 +47,6 @@ public class PhysicCable : MonoBehaviour
|
||||
[SerializeField] private float plugMaxTurnStep = 0.11f; // 每步最大转角(弧度)
|
||||
|
||||
[Header("插拔手感")]
|
||||
[SerializeField] private bool enableSocketAssist = true;
|
||||
[SerializeField] private float defaultAssistRadius = 1.45f; // 没有外部半径时的吸附范围
|
||||
[SerializeField, Range(0f, 1f)] private float socketAssistStrength = 0.62f;
|
||||
[SerializeField] private float plugSnapRate = 0.55f;
|
||||
[SerializeField] private float insertImpactDuration = 0.22f;
|
||||
[SerializeField] private float insertShoveDistance = 0.18f;
|
||||
@@ -115,9 +112,6 @@ public class PhysicCable : MonoBehaviour
|
||||
private Transform _dock; // 当前插入的插孔
|
||||
private Vector3 _plugSnapEnd; // 插接吸附目标:渐进收敛到孔心后末端硬钉,保证完全对齐堵住孔
|
||||
private float _plugAngle = -Mathf.PI / 2f; // 插头朝向(弧度,初始朝下)
|
||||
private Transform _dragAssistDock;
|
||||
private float _dragAssistRadius;
|
||||
private float _dragAssistBlend;
|
||||
private bool _unplugResisting;
|
||||
private Vector3 _unplugAnchor;
|
||||
private float _insertImpactTimer;
|
||||
@@ -145,7 +139,6 @@ public class PhysicCable : MonoBehaviour
|
||||
{
|
||||
State = CableState.Hidden;
|
||||
_dock = null;
|
||||
ClearDragAssistTarget();
|
||||
_unplugResisting = false;
|
||||
_insertImpactTimer = 0f;
|
||||
SetCableRenderersEnabled(false);
|
||||
@@ -157,7 +150,6 @@ public class PhysicCable : MonoBehaviour
|
||||
EnsureInit();
|
||||
if (resetShape) ResetHangingShape();
|
||||
_dock = null;
|
||||
ClearDragAssistTarget();
|
||||
_unplugResisting = false;
|
||||
State = CableState.Free;
|
||||
SetCableRenderersEnabled(true);
|
||||
@@ -188,29 +180,10 @@ public class PhysicCable : MonoBehaviour
|
||||
if (State == CableState.Dragging)
|
||||
{
|
||||
State = CableState.Free;
|
||||
ClearDragAssistTarget();
|
||||
_unplugResisting = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDragAssistTarget(Transform dock, float radius)
|
||||
{
|
||||
if (!enableSocketAssist || dock == null)
|
||||
{
|
||||
ClearDragAssistTarget();
|
||||
return;
|
||||
}
|
||||
|
||||
_dragAssistDock = dock;
|
||||
_dragAssistRadius = Mathf.Max(0.01f, radius > 0f ? radius : defaultAssistRadius);
|
||||
}
|
||||
|
||||
public void ClearDragAssistTarget()
|
||||
{
|
||||
_dragAssistDock = null;
|
||||
_dragAssistBlend = 0f;
|
||||
}
|
||||
|
||||
public void StartUnplugResistance(Transform socket)
|
||||
{
|
||||
if (socket == null || _pts == null) return;
|
||||
@@ -221,7 +194,6 @@ public class PhysicCable : MonoBehaviour
|
||||
_pts[_n - 1].pos = _unplugAnchor;
|
||||
_pts[_n - 1].prev = _unplugAnchor;
|
||||
_unplugResisting = unplugBreakDistance > 0.01f;
|
||||
ClearDragAssistTarget();
|
||||
}
|
||||
|
||||
/// <summary>末端钉到插孔;snapStraight 用于读档,把绳直接摆成出线口到插孔的直线。</summary>
|
||||
@@ -229,7 +201,6 @@ public class PhysicCable : MonoBehaviour
|
||||
{
|
||||
EnsureInit();
|
||||
_dock = dock;
|
||||
ClearDragAssistTarget();
|
||||
_unplugResisting = false;
|
||||
State = CableState.Plugged;
|
||||
SetCableRenderersEnabled(true);
|
||||
@@ -353,7 +324,7 @@ public class PhysicCable : MonoBehaviour
|
||||
}
|
||||
|
||||
// --- 拖拽目标:重 lerp + 按当前绳长钳制(拽满时目标跟着绳长走,消除抖动)
|
||||
Vector3 dragPointer = dragging ? GetAssistedPointer(_pointer) : _pointer;
|
||||
Vector3 dragPointer = _pointer;
|
||||
if (dragging)
|
||||
{
|
||||
_dragTarget += (dragPointer - _dragTarget) * dragFollowRate;
|
||||
@@ -496,23 +467,6 @@ public class PhysicCable : MonoBehaviour
|
||||
return Vector3.Lerp(_unplugAnchor, rawPointer, eased);
|
||||
}
|
||||
|
||||
private Vector3 GetAssistedPointer(Vector3 pointer)
|
||||
{
|
||||
if (!enableSocketAssist || _dragAssistDock == null || State != CableState.Dragging)
|
||||
{
|
||||
_dragAssistBlend = Mathf.MoveTowards(_dragAssistBlend, 0f, 0.18f);
|
||||
return pointer;
|
||||
}
|
||||
|
||||
Vector3 dock = FlattenZ(_dragAssistDock.position);
|
||||
float dist = Vector3.Distance(pointer, dock);
|
||||
float targetBlend = Mathf.Clamp01(1f - dist / Mathf.Max(0.01f, _dragAssistRadius));
|
||||
targetBlend = targetBlend * targetBlend * (3f - 2f * targetBlend);
|
||||
targetBlend *= socketAssistStrength;
|
||||
_dragAssistBlend = Mathf.MoveTowards(_dragAssistBlend, targetBlend, 0.14f);
|
||||
return Vector3.Lerp(pointer, dock, _dragAssistBlend);
|
||||
}
|
||||
|
||||
private void BeginInsertImpact(Transform dock)
|
||||
{
|
||||
if (dock == null || IsInsertImpactDisabled()) return;
|
||||
|
||||
@@ -284,7 +284,6 @@ namespace AibisDream.FixSystem
|
||||
{
|
||||
targetModule.OpenPlugSlot();
|
||||
BodyModuleSystem.CloseModuleSlots(targetModule);
|
||||
physicCableRef.SetDragAssistTarget(targetModule.GetSocketPos(), assistRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -294,7 +293,6 @@ namespace AibisDream.FixSystem
|
||||
|
||||
public void ClearDragHighlight()
|
||||
{
|
||||
physicCableRef?.ClearDragAssistTarget();
|
||||
BodyModuleSystem?.CloseModuleSlots(null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user