新增脚本

This commit is contained in:
2025-12-26 23:11:06 +08:00
parent 45129be7dc
commit 028d054705
153 changed files with 2783 additions and 15441 deletions

View 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;
}
}