新增脚本
This commit is contained in:
35
Assets/Scripts/Fishing/Rope/Rope.cs
Normal file
35
Assets/Scripts/Fishing/Rope/Rope.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user