Files
Fishing2/Assets/Scripts/Fishing/Rope/Rope.cs
2025-12-26 23:11:06 +08:00

35 lines
796 B
C#

using NBF;
using Obi;
using UnityEngine;
public class Rope : MonoBehaviour
{
private FRod _rod;
[SerializeField] private ObiRope rope;
[SerializeField] private ObiRopeCursor cursor;
[SerializeField] private float percentageElasticity = 0.2f;
private float stretchScale;
private void Awake()
{
rope = GetComponent<ObiRope>();
if (_rod)
{
LineLength_OnValueChanged(_rod.lineLength);
}
}
public void LineLength_OnValueChanged(float length)
{
cursor = ((cursor == null) ? GetComponent<ObiRopeCursor>() : cursor);
stretchScale = Mathf.Clamp(length - percentageElasticity, 0f, float.PositiveInfinity);
}
private void Update()
{
rope.stretchingScale = stretchScale;
}
}