diff --git a/Assets/Scenes/Reparation.unity b/Assets/Scenes/Reparation.unity index 1fcb313..f1fd575 100644 --- a/Assets/Scenes/Reparation.unity +++ b/Assets/Scenes/Reparation.unity @@ -17337,6 +17337,10 @@ PrefabInstance: propertyPath: audioSource value: objectReference: {fileID: 1128651442} + - target: {fileID: 4614605577419265582, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3} + propertyPath: welderPrefab + value: + objectReference: {fileID: 1071434719} - target: {fileID: 4614605577419265582, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3} propertyPath: weldingSound value: diff --git a/Assets/Scripts/FixLogic.cs b/Assets/Scripts/FixLogic.cs index 15534d6..abfa766 100644 --- a/Assets/Scripts/FixLogic.cs +++ b/Assets/Scripts/FixLogic.cs @@ -9,6 +9,7 @@ public class FixLogic : MonoBehaviour public AudioClip weldingSound; public GameObject welderParticles; public Welder welder; + public GameObject welderPrefab; // Minimap circles and particles public GameObject circle0; @@ -46,7 +47,7 @@ private void OnTriggerEnter(Collider other) if (!other.CompareTag("Leak")) return; _isOverlapping = true; _currentLeak = other.gameObject; - Debug.Log("Overlapping with leak. Hold 'F' to fix."); + StartCoroutine(RotateWelder()); } private void OnTriggerExit(Collider other) @@ -87,6 +88,8 @@ private IEnumerator FixLeak() yield return null; } + StartCoroutine(RotateWelder()); + if (!_isOverlapping || _currentLeak == null) { Debug.Log("No longer overlapping with leak. Fix aborted."); @@ -106,6 +109,8 @@ private IEnumerator FixLeak() _isOverlapping = false; _isFixing = false; + + StartCoroutine(RotateWelder()); } private void HandleMinimapCirclesAndParticles() @@ -169,4 +174,25 @@ private static void GameOver() { Debug.Log("Game Over! You fixed 7 leaks."); } + + private IEnumerator RotateWelder() + { + var originalRotation = welderPrefab.transform.rotation; + var targetRotation = originalRotation * Quaternion.Euler(10f, 10f, 0f); + + const float rotateDuration = 0.5f; + for (float t = 0; t < rotateDuration; t += Time.deltaTime) + { + welderPrefab.transform.rotation = Quaternion.Lerp(originalRotation, targetRotation, t / rotateDuration); + yield return null; + } + welderPrefab.transform.rotation = targetRotation; + + for (float t = 0; t < rotateDuration; t += Time.deltaTime) + { + welderPrefab.transform.rotation = Quaternion.Lerp(targetRotation, originalRotation, t / rotateDuration); + yield return null; + } + welderPrefab.transform.rotation = originalRotation; + } }