35 lines
860 B
C#
35 lines
860 B
C#
using Obi;
|
|
using UnityEngine;
|
|
|
|
namespace NBF
|
|
{
|
|
/// <summary>
|
|
/// 基于obi rope的鱼线控制脚本
|
|
/// </summary>
|
|
public class RopeByObi : RopeBase
|
|
{
|
|
[SerializeField] private ObiRope rope;
|
|
|
|
[SerializeField] private ObiRopeCursor cursor;
|
|
|
|
[SerializeField] private float percentageElasticity = 0.2f;
|
|
|
|
private float _stretchScale;
|
|
|
|
private void Awake()
|
|
{
|
|
rope = GetComponent<ObiRope>();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
rope.stretchingScale = _stretchScale;
|
|
}
|
|
|
|
protected override void OnSetLineLength(float length)
|
|
{
|
|
cursor = ((cursor == null) ? GetComponent<ObiRopeCursor>() : cursor);
|
|
_stretchScale = Mathf.Clamp(length - percentageElasticity, 0f, float.PositiveInfinity);
|
|
}
|
|
}
|
|
} |