Files
Ultimate-Fishing-Simulator-…/Assets/Scripts/Assembly-CSharp/Rope.cs
2026-03-04 09:37:33 +08:00

38 lines
727 B
C#

using Obi;
using Obvious.Soap;
using UnityEngine;
public class Rope : MonoBehaviour
{
[SerializeField]
private ObiRope rope;
[SerializeField]
private ObiRopeCursor cursor;
[SerializeField]
private float percentageElasticity = 0.2f;
[SerializeField]
private FloatVariable lineLength;
private float stretchScale;
private void Awake()
{
rope = GetComponent<ObiRope>();
LineLength_OnValueChanged(lineLength.Value);
}
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;
}
}