fix: dragging units can no longer go haywire and yeet units off the map

This commit is contained in:
Chris
2025-12-06 18:29:20 -05:00
parent 557979f470
commit 5f7179c861

View File

@@ -112,6 +112,9 @@ public class UnitCombat : UnitComponent {
Debug.LogError($"No available UnitMovement on {draggedUnit.name}. Aborting drag on this unit."); Debug.LogError($"No available UnitMovement on {draggedUnit.name}. Aborting drag on this unit.");
continue; continue;
} }
// Prevent units from entering a runaway situation where they constantly pull each other at high speeds across the map
speedDelta = Mathf.Min(speedDelta, draggedUnitMovement.data.moveSpeed.Value);
draggedUnitMovement.SetNewRotation(-transform.position.DirectionTo(draggedUnit.transform.position), 1f, true); draggedUnitMovement.SetNewRotation(-transform.position.DirectionTo(draggedUnit.transform.position), 1f, true);
draggedUnitMovement.SetNewDirection(positionDelta.ToVector2(), 1f, true); draggedUnitMovement.SetNewDirection(positionDelta.ToVector2(), 1f, true);