小问题修复,优化切割手感

This commit is contained in:
2025-11-17 22:27:13 +08:00
parent bf368e5aa7
commit 110419635f
5 changed files with 985 additions and 822 deletions
+1 -1
View File
@@ -430,7 +430,7 @@ MonoBehaviour:
targetSpriteRenderer: {fileID: 0}
snapDistance: 0.3
detachDistance: 100
tractionSpeed: 2.5
tractionSpeed: 3
edgePointsScale: 1.2
cutLineRenderer: {fileID: 8826702205418835467}
cutLineWidth: 0.1
@@ -113,10 +113,26 @@ ScriptedImporter:
spriteBone: []
spriteOutline: []
vertices: []
spritePhysicsOutline: []
spritePhysicsOutline:
- outline:
- {x: 47.5, y: 18}
- {x: 38.5, y: 20}
- {x: 33.5, y: 25}
- {x: 25.5, y: 33}
- {x: -30.5, y: 33}
- {x: -38.5, y: 25}
- {x: -46.5, y: 25}
- {x: -46.5, y: 9}
- {x: -46.5, y: -24}
- {x: -39.5, y: -26}
- {x: -32.5, y: -32}
- {x: -7.5, y: -32}
- {x: 25.5, y: -32}
- {x: 39.5, y: -16}
- {x: 47.5, y: -16}
indices:
edges: []
tessellationDetail: 0
tessellationDetail: 0.76
uvTransform: {x: 396, y: 96}
spritePosition: {x: 275, y: 57}
- name: "\u60C5\u7EEA\u6A21\u5757"
@@ -134,10 +150,36 @@ ScriptedImporter:
spriteBone: []
spriteOutline: []
vertices: []
spritePhysicsOutline: []
spritePhysicsOutline:
- outline:
- {x: 38.5, y: -14}
- {x: 37.5, y: 26}
- {x: 25.5, y: 37}
- {x: 16.5, y: 39}
- {x: 9.5, y: 39}
- {x: -9.5, y: 39}
- {x: -35.5, y: 38}
- {x: -39.5, y: 35}
- {x: -39.5, y: 12}
- {x: -42.5, y: 7}
- {x: -42.5, y: -15}
- {x: -35.5, y: -23}
- {x: -35.5, y: -28}
- {x: -34.5, y: -32}
- {x: -27.5, y: -33}
- {x: -12.5, y: -33}
- {x: -9.5, y: -30}
- {x: -6.5, y: -27}
- {x: 4.5, y: -27}
- {x: 7.5, y: -31}
- {x: 7.5, y: -39}
- {x: 21.5, y: -40}
- {x: 30.5, y: -34}
- {x: 33.5, y: -24}
- {x: 37.5, y: -20}
indices:
edges: []
tessellationDetail: 0
tessellationDetail: 0.66
uvTransform: {x: 396, y: 4}
spritePosition: {x: 28, y: 46}
- name: "\u8BB0\u5FC6\u6A21\u5757"
@@ -155,10 +197,26 @@ ScriptedImporter:
spriteBone: []
spriteOutline: []
vertices: []
spritePhysicsOutline: []
spritePhysicsOutline:
- outline:
- {x: 58, y: 17}
- {x: 50, y: 30}
- {x: 36, y: 40}
- {x: -14, y: 40}
- {x: -23, y: 34}
- {x: -23, y: 12}
- {x: -25, y: 2}
- {x: -53, y: 2}
- {x: -60, y: -4}
- {x: -60, y: -27}
- {x: -54, y: -39}
- {x: -12, y: -38}
- {x: 33, y: -38}
- {x: 47, y: -33}
- {x: 59, y: -19}
indices:
edges: []
tessellationDetail: 0
tessellationDetail: 0.4
uvTransform: {x: 4, y: 228}
spritePosition: {x: 116, y: 83}
- name: "\u5185\u90E8\u6784\u9020"
+13 -9
View File
@@ -463,15 +463,19 @@ MonoBehaviour:
m_PostInfinity: 2
m_RotationOrder: 4
_filter:
- 0.007228916
- 0.043749984
- 0.12409639
- 0.20444278
- 0.24096388
- 0.20444278
- 0.12409639
- 0.043749984
- 0.007228916
- 0.0048309183
- 0.016401261
- 0.04532712
- 0.08293076
- 0.12053438
- 0.14946026
- 0.1610306
- 0.14946026
- 0.12053438
- 0.08293076
- 0.04532712
- 0.016401261
- 0.0048309183
--- !u!114 &-6086986437317696584
MonoBehaviour:
m_ObjectHideFlags: 3
File diff suppressed because it is too large Load Diff
@@ -410,10 +410,21 @@ public class GearFollower : MonoBehaviour
Vector2 toMouse = (mousePos - from).normalized;
float angle = Vector2.SignedAngle(forward, toMouse);
if (Mathf.Abs(angle) > 120f)
// 优化:计算当前段的角度,判断是否为尖角
int prevIndex = WrapIndex(currentEdgeIndex - tractionDirection);
Vector2 prevPoint = edgePoints[prevIndex];
Vector2 prevSegment = (from - prevPoint).normalized;
float segmentAngle = Vector2.Angle(prevSegment, forward);
bool isSharpCorner = segmentAngle > 60f; // 夹角大于60度认为是尖角
// 动态调整方向切换阈值和冷却时间
float switchAngleThreshold = isSharpCorner ? 90f : 120f;
float currentCooldown = isSharpCorner ? 0.05f : directionSwitchCooldown;
if (Mathf.Abs(angle) > switchAngleThreshold)
{
directionSwitchTimer += Time.deltaTime;
if (directionSwitchTimer > directionSwitchCooldown)
if (directionSwitchTimer > currentCooldown)
{
tractionDirection *= -1;
directionSwitchTimer = 0f;
@@ -433,7 +444,9 @@ public class GearFollower : MonoBehaviour
Vector2 moveDir = (targetPoint - gearPos);
float distance = moveDir.magnitude;
float maxStep = tractionSpeed * Time.deltaTime;
// 动态调整牵引速度:在尖角处提速
float speedMultiplier = isSharpCorner ? 1.5f : 1.0f;
float maxStep = tractionSpeed * speedMultiplier * Time.deltaTime;
if (distance <= maxStep)
{