Skip to content

Commit c0bd590

Browse files
committed
feat: welder rotation on fix
1 parent 0d4bf8b commit c0bd590

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

Assets/Scenes/Reparation.unity

+4
Original file line numberDiff line numberDiff line change
@@ -17337,6 +17337,10 @@ PrefabInstance:
1733717337
propertyPath: audioSource
1733817338
value:
1733917339
objectReference: {fileID: 1128651442}
17340+
- target: {fileID: 4614605577419265582, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
17341+
propertyPath: welderPrefab
17342+
value:
17343+
objectReference: {fileID: 1071434719}
1734017344
- target: {fileID: 4614605577419265582, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
1734117345
propertyPath: weldingSound
1734217346
value:

Assets/Scripts/FixLogic.cs

+27-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class FixLogic : MonoBehaviour
99
public AudioClip weldingSound;
1010
public GameObject welderParticles;
1111
public Welder welder;
12+
public GameObject welderPrefab;
1213

1314
// Minimap circles and particles
1415
public GameObject circle0;
@@ -46,7 +47,7 @@ private void OnTriggerEnter(Collider other)
4647
if (!other.CompareTag("Leak")) return;
4748
_isOverlapping = true;
4849
_currentLeak = other.gameObject;
49-
Debug.Log("Overlapping with leak. Hold 'F' to fix.");
50+
StartCoroutine(RotateWelder());
5051
}
5152

5253
private void OnTriggerExit(Collider other)
@@ -87,6 +88,8 @@ private IEnumerator FixLeak()
8788
yield return null;
8889
}
8990

91+
StartCoroutine(RotateWelder());
92+
9093
if (!_isOverlapping || _currentLeak == null)
9194
{
9295
Debug.Log("No longer overlapping with leak. Fix aborted.");
@@ -106,6 +109,8 @@ private IEnumerator FixLeak()
106109

107110
_isOverlapping = false;
108111
_isFixing = false;
112+
113+
StartCoroutine(RotateWelder());
109114
}
110115

111116
private void HandleMinimapCirclesAndParticles()
@@ -169,4 +174,25 @@ private static void GameOver()
169174
{
170175
Debug.Log("Game Over! You fixed 7 leaks.");
171176
}
177+
178+
private IEnumerator RotateWelder()
179+
{
180+
var originalRotation = welderPrefab.transform.rotation;
181+
var targetRotation = originalRotation * Quaternion.Euler(10f, 10f, 0f);
182+
183+
const float rotateDuration = 0.5f;
184+
for (float t = 0; t < rotateDuration; t += Time.deltaTime)
185+
{
186+
welderPrefab.transform.rotation = Quaternion.Lerp(originalRotation, targetRotation, t / rotateDuration);
187+
yield return null;
188+
}
189+
welderPrefab.transform.rotation = targetRotation;
190+
191+
for (float t = 0; t < rotateDuration; t += Time.deltaTime)
192+
{
193+
welderPrefab.transform.rotation = Quaternion.Lerp(targetRotation, originalRotation, t / rotateDuration);
194+
yield return null;
195+
}
196+
welderPrefab.transform.rotation = originalRotation;
197+
}
172198
}

0 commit comments

Comments
 (0)