This commit is contained in:
2025-01-25 17:45:16 +08:00
parent 5703efd59e
commit c360b3c869
6 changed files with 147 additions and 64 deletions
@@ -1,4 +1,5 @@
using System;
using System.Drawing;
using DG.Tweening.Plugins.Core.PathCore;
using UnityEngine;
@@ -8,8 +9,6 @@ namespace AibisDream.FixSystem
public class Cable : MonoBehaviour
{
private Transform _start;
public Transform _controlPoint;
private Transform _end;
private LineRenderer _lineRenderer;
@@ -29,7 +28,7 @@ namespace AibisDream.FixSystem
private void InitComponentRefs()
{
_cableSystem = transform.parent.GetComponent<CableSystem>();
_lineRenderer = GetComponent<LineRenderer>();
_lineRenderer.positionCount = config.resolution;
@@ -64,13 +63,11 @@ namespace AibisDream.FixSystem
Vector3[] UpdateRope()
{
float t = Mathf.InverseLerp(config.dstMin, config.dstMax, (_start.position - _end.position).magnitude);
float F = Mathf.Lerp(config.forceMin, config.forceMax, t);
_points[0] = _start.position;
_points[1] = _controlPoint.position;
_points[^1] = _end.position;
_points[^1] = _end.GetChild(0).position;
for (int ik = 0; ik < config.k; ik++)
{
for (int i = 1; i < _points.Length - 1; i++)
@@ -99,8 +96,12 @@ namespace AibisDream.FixSystem
{
_end = endPos;
}
public Vector3 GetDirection()
{
return _points[^1]-_points[_points.Length-1];
}
}
[Serializable]
public struct CableConfig
{
+4 -17
View File
@@ -55,10 +55,11 @@ namespace AibisDream.FixSystem
{
//InsertSocket(initSocket);
}
public void InitPlug()
public void Update()
{
_cableSystem.PhysicCableRef.Init();
//_cableSystem.PhysicCableRef.physicLine.UpdatePlug(this.transform);
//_cableSystem.PhysicCableRef.physicLine.UpdateEndPoint(this.transform);
_cableSystem.PhysicCableRef.physicLine.UpdatePlug(this.transform);
}
/// <summary>
@@ -155,20 +156,6 @@ namespace AibisDream.FixSystem
// });
}
}
public void Update()
{
_cableSystem.PhysicCableRef.physicLine.UpdateEndPoint(this.transform.position);
// if(_cableSystem.curSocket!=null&&_isDragging==false)
// {
// _cableSystem.PhysicCableRef.physicLine.UpdatePlug(this.transform);
// }
// else
// {
// _cableSystem.PhysicCableRef.physicLine.UpdateLine(this.transform);
// }
}
private void AdjustPlugPos()
{