修改水

This commit is contained in:
2026-01-01 22:00:33 +08:00
parent 040a222bd6
commit 9ceffccd39
1800 changed files with 103929 additions and 139495 deletions

View File

@@ -1,50 +0,0 @@
using UnityEngine;
namespace Obi.Samples
{
public class PinholeRatchet : MonoBehaviour
{
public ObiPinhole pinhole;
public bool direction = false;
public float teethSeparation = 0.1f;
public float distanceToNextTooth { get; private set; }
void Update()
{
if (pinhole == null || pinhole.rope == null)
return;
float restLength = (pinhole.rope as ObiRopeBase).restLength;
float normalizedTeethDistance = Mathf.Max(0.001f, teethSeparation / restLength);
var range = pinhole.range;
if (direction)
{
distanceToNextTooth = (range.y - pinhole.position) * restLength;
while (distanceToNextTooth > teethSeparation)
{
range.y -= normalizedTeethDistance;
distanceToNextTooth -= teethSeparation;
}
}
else
{
distanceToNextTooth = (pinhole.position - range.x) * restLength;
while (distanceToNextTooth > teethSeparation)
{
range.x += normalizedTeethDistance;
distanceToNextTooth -= teethSeparation;
}
}
pinhole.range = range;
}
public void OnDisable()
{
if (pinhole != null)
pinhole.range = new Vector2(0, 1);
}
}
}