完成捏住鱼线逻辑
This commit is contained in:
@@ -9,8 +9,6 @@ namespace NBF
|
||||
[SerializeField] private float moveSpeed = 5f;
|
||||
[SerializeField] private float snapDistance = 0.1f;
|
||||
|
||||
// 组件引用
|
||||
private ConfigurableJoint originalSpringJoint;
|
||||
private FixedJoint pinchJoint;
|
||||
private Rigidbody rb;
|
||||
|
||||
@@ -22,15 +20,13 @@ namespace NBF
|
||||
|
||||
|
||||
public bool isPinched { get; private set; }
|
||||
|
||||
|
||||
|
||||
private bool moveToTargetDone;
|
||||
private float _speed;
|
||||
|
||||
void Start()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
originalSpringJoint = GetComponent<ConfigurableJoint>();
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
@@ -38,21 +34,22 @@ namespace NBF
|
||||
if (isPinched && !moveToTargetDone && targetTransform != null)
|
||||
{
|
||||
pinchElapsedTime += Time.fixedDeltaTime;
|
||||
// transform.position =
|
||||
// Vector3.MoveTowards(transform.position, targetTransform.position, Time.deltaTime * _speed);
|
||||
rb.MovePosition(Vector3.MoveTowards(transform.position, targetTransform.position,
|
||||
Time.deltaTime * _speed));
|
||||
transform.position =
|
||||
Vector3.MoveTowards(transform.position, targetTransform.position, Time.deltaTime * _speed);
|
||||
if (Vector3.Distance(transform.position, targetTransform.position) < 0.1f ||
|
||||
pinchElapsedTime >= maxCatchupDuration)
|
||||
{
|
||||
moveToTargetDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
SyncPosition();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
// SyncPosition();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
SyncPosition();
|
||||
}
|
||||
@@ -61,7 +58,7 @@ namespace NBF
|
||||
{
|
||||
if (!isPinched) return;
|
||||
if (!moveToTargetDone) return;
|
||||
rb.MovePosition(targetTransform.position);
|
||||
transform.position = targetTransform.position;
|
||||
}
|
||||
|
||||
// 外部调用:开始捏住流程
|
||||
|
||||
@@ -79,6 +79,7 @@ namespace NBF
|
||||
if (PlayerItem.StretchRope)
|
||||
{
|
||||
Line.SetTargetLength(PlayerItem.Tension > 0f ? 0f : PlayerItem.LineLength - PlayerItem.FloatLength);
|
||||
Line.SetLureLength(PlayerItem.FloatLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user