38 lines
800 B
C#
38 lines
800 B
C#
using NBF;
|
|
using Obi;
|
|
using UnityEngine;
|
|
|
|
public class Rope : MonoBehaviour
|
|
{
|
|
private FRod _rod;
|
|
public bool isFloatRope;
|
|
[SerializeField] private ObiRope rope;
|
|
|
|
[SerializeField] private ObiRopeCursor cursor;
|
|
|
|
[SerializeField] private float percentageElasticity = 0.2f;
|
|
|
|
private float stretchScale;
|
|
|
|
private void Awake()
|
|
{
|
|
rope = GetComponent<ObiRope>();
|
|
}
|
|
|
|
public void Init(FRod rod)
|
|
{
|
|
_rod = rod;
|
|
}
|
|
|
|
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;
|
|
}
|
|
} |