diff --git a/Assets/Audio/AudioLibrary.asset b/Assets/Audio/AudioLibrary.asset index eb3f45f..fc959b9 100644 --- a/Assets/Audio/AudioLibrary.asset +++ b/Assets/Audio/AudioLibrary.asset @@ -36,7 +36,6 @@ MonoBehaviour: - {fileID: 8300000, guid: 2fc5510c93077614ea99731a8e690f6b, type: 3} - {fileID: 8300000, guid: 27f2cebd20efe6a4faf50b23ad487154, type: 3} - {fileID: 8300000, guid: fc82c40acffc19741a0707c947a1d767, type: 3} - - {fileID: 8300000, guid: 2a5efb61897b6af4ab3ecae350829b5c, type: 3} - {fileID: 8300000, guid: 6778ae1bc0a92c64d8ba759c3c13727d, type: 3} - {fileID: 8300000, guid: 7182af998117fba4fa696e5fd33ad99a, type: 3} - {fileID: 8300000, guid: 88b0c2079547b85458daa063fb59e720, type: 3} @@ -44,3 +43,4 @@ MonoBehaviour: - {fileID: 8300000, guid: 8abb5f3f03f30f842b9d673933bdafb4, type: 3} - {fileID: 8300000, guid: f68b9fed55ed886479faaf1b33c59651, type: 3} - {fileID: 8300000, guid: e24c2fccb4285ab4eacc6da16f5c62eb, type: 3} + - {fileID: 8300000, guid: fd92966d4cde3244d9a711094cb947f6, type: 3} diff --git a/Assets/Audio/Rope_Tight_SFX.mp3 b/Assets/Audio/Rope_Tight_SFX.mp3 deleted file mode 100644 index 8671c7b..0000000 Binary files a/Assets/Audio/Rope_Tight_SFX.mp3 and /dev/null differ diff --git a/Assets/Audio/Rope_Tight_SFX.wav b/Assets/Audio/Rope_Tight_SFX.wav new file mode 100644 index 0000000..747139d Binary files /dev/null and b/Assets/Audio/Rope_Tight_SFX.wav differ diff --git a/Assets/Audio/Rope_Tight_SFX.mp3.meta b/Assets/Audio/Rope_Tight_SFX.wav.meta similarity index 91% rename from Assets/Audio/Rope_Tight_SFX.mp3.meta rename to Assets/Audio/Rope_Tight_SFX.wav.meta index ad7066d..1c8b47f 100644 --- a/Assets/Audio/Rope_Tight_SFX.mp3.meta +++ b/Assets/Audio/Rope_Tight_SFX.wav.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4d9817ed7f73fc14db871e07a93a5931 +guid: fd92966d4cde3244d9a711094cb947f6 AudioImporter: externalObjects: {} serializedVersion: 7 diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index e578c2e..b162b84 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -3421,7 +3421,7 @@ MonoBehaviour: m_CorrespondingSourceObject: {fileID: 7717684785049474632, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3} m_PrefabInstance: {fileID: 4910321061857220295} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} + m_GameObject: {fileID: 4910321061857220296} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 27ac133d9e10e544ba603e07122e3359, type: 3} @@ -3737,8 +3737,128 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 5991265243222894942, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3} + insertIndex: -1 + addedObject: {fileID: 4910321061857220297} + - targetCorrespondingSourceObject: {fileID: 5991265243222894942, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3} + insertIndex: -1 + addedObject: {fileID: 4910321061857220300} m_SourcePrefab: {fileID: 100100000, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3} +--- !u!1 &4910321061857220296 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 5991265243222894942, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3} + m_PrefabInstance: {fileID: 4910321061857220295} + m_PrefabAsset: {fileID: 0} +--- !u!114 &4910321061857220297 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4910321061857220296} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8766ad5393174fa488ef4a58b62181b4, type: 3} + m_Name: + m_EditorClassIdentifier: + PlayTime: 1 +--- !u!82 &4910321061857220300 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4910321061857220296} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 8300000, guid: fd92966d4cde3244d9a711094cb947f6, type: 3} + m_PlayOnAwake: 0 + m_Volume: 0.107 + m_Pitch: 1 + Loop: 1 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 --- !u!1001 &5796191506433166633 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Extensions/Vector3Extensions.cs b/Assets/Scripts/Extensions/Vector3Extensions.cs index b5c3fe0..e7d108f 100644 --- a/Assets/Scripts/Extensions/Vector3Extensions.cs +++ b/Assets/Scripts/Extensions/Vector3Extensions.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; +using System; using UnityEngine; namespace UnityUtils @@ -56,5 +58,22 @@ namespace UnityUtils v1.y != 0 ? v0.y / v1.y : v0.y, v1.z != 0 ? v0.z / v1.z : v0.z); } + public static Vector3 Mean(this List vectors) + { + if (vectors == null || vectors.Count == 0) + { + throw new ArgumentException("The input list of vectors is empty or null."); + } + + Vector3 sum = Vector3.zero; + + foreach (var vector in vectors) + { + sum += vector; + } + + return sum / vectors.Count; + } } + } diff --git a/Assets/Scripts/Managers/AudioManager/AudioManager.cs b/Assets/Scripts/Managers/AudioManager/AudioManager.cs index 6194e8d..4c4a798 100644 --- a/Assets/Scripts/Managers/AudioManager/AudioManager.cs +++ b/Assets/Scripts/Managers/AudioManager/AudioManager.cs @@ -36,7 +36,7 @@ public class AudioManager : MonoBehaviour return Instance.audioLibrary.Clips.First(x => x.name == nameOfClip); } - public static AudioSource PlaySound(string nameOfClip, Vector3 sourcePos, bool is3D = true, bool loop = false, bool fadeIn = false) + public static AudioSource PlaySound(string nameOfClip, Vector3 sourcePos, bool manuallyHandle = false, bool is3D = true, bool loop = false, bool fadeIn = false) { if (Instance == null) { @@ -57,7 +57,8 @@ public class AudioManager : MonoBehaviour audioSource.spatialBlend = 1f; } - Instance.StartCoroutine(Instance.StartSound(audioSource, fadeIn)); + if (!manuallyHandle) + Instance.StartCoroutine(Instance.StartSound(audioSource, fadeIn)); return audioSource; } diff --git a/Assets/Scripts/Rope/RopeSimulator.cs b/Assets/Scripts/Rope/RopeSimulator.cs index 0750fd5..8cc02ea 100644 --- a/Assets/Scripts/Rope/RopeSimulator.cs +++ b/Assets/Scripts/Rope/RopeSimulator.cs @@ -66,7 +66,7 @@ public class RopeSimulator : MonoBehaviour public float Overshoot => rope.CalculateLengthOvershoot(); - Rope rope; + public Rope rope; Dictionary colliderToSquezeForce = new(); diff --git a/Assets/Sounding.meta b/Assets/Sounding.meta new file mode 100644 index 0000000..cbf48ff --- /dev/null +++ b/Assets/Sounding.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4d19feedeaa6e99458ae00d9141125be +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sounding/RopeSounding.cs b/Assets/Sounding/RopeSounding.cs new file mode 100644 index 0000000..140c043 --- /dev/null +++ b/Assets/Sounding/RopeSounding.cs @@ -0,0 +1,47 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityUtils; + +public class RopeSounding : MonoBehaviour +{ + [SerializeField] private float PlayTime = 1f; + + RopeSimulator rope; + + AudioSource AS; + float playTimeLeft = 0; + + // Update is called once per frame + void Update() + { + if (rope == null) + { + if (TryGetComponent(out rope)) + { + + } + } + + if (AS == null) + { + TryGetComponent(out AS); + AS.Play(); + AS.Pause(); + } + + + if (rope.Overshoot >= 0.5f) + { + Vector3 soundPos = rope.rope.points.Select(x => x.position).ToList().Mean(); + AS.transform.position = soundPos; + AS.UnPause(); + } + else + { + // Pause + AS.Pause(); + } + } +} \ No newline at end of file diff --git a/Assets/Sounding/RopeSounding.cs.meta b/Assets/Sounding/RopeSounding.cs.meta new file mode 100644 index 0000000..c68017e --- /dev/null +++ b/Assets/Sounding/RopeSounding.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8766ad5393174fa488ef4a58b62181b4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: