From 3b7891a262575bec037c64b7a57151343d81e839 Mon Sep 17 00:00:00 2001 From: cross28 Date: Sun, 17 Apr 2022 23:31:58 -0500 Subject: feat: Added projectile sound effect --- Assets/Resources/SoundEffects.meta | 8 ++ Assets/Resources/SoundEffects/Gunshot.mp3 | Bin 0 -> 18045 bytes Assets/Resources/SoundEffects/Gunshot.mp3.meta | 22 +++++ Assets/Scenes/Jungle.unity | 114 +++++++++++++++++++++++++ Assets/Scripts/Actors/Player.cs | 1 + Assets/Scripts/SoundManager.cs | 18 ++++ Assets/Scripts/SoundManager.cs.meta | 11 +++ 7 files changed, 174 insertions(+) create mode 100644 Assets/Resources/SoundEffects.meta create mode 100644 Assets/Resources/SoundEffects/Gunshot.mp3 create mode 100644 Assets/Resources/SoundEffects/Gunshot.mp3.meta create mode 100644 Assets/Scripts/SoundManager.cs create mode 100644 Assets/Scripts/SoundManager.cs.meta (limited to 'Assets') diff --git a/Assets/Resources/SoundEffects.meta b/Assets/Resources/SoundEffects.meta new file mode 100644 index 0000000..5e13e46 --- /dev/null +++ b/Assets/Resources/SoundEffects.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1eaebbafac1cac241be7c1b30a019bb8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/SoundEffects/Gunshot.mp3 b/Assets/Resources/SoundEffects/Gunshot.mp3 new file mode 100644 index 0000000..3b1edb0 Binary files /dev/null and b/Assets/Resources/SoundEffects/Gunshot.mp3 differ diff --git a/Assets/Resources/SoundEffects/Gunshot.mp3.meta b/Assets/Resources/SoundEffects/Gunshot.mp3.meta new file mode 100644 index 0000000..c28f5e9 --- /dev/null +++ b/Assets/Resources/SoundEffects/Gunshot.mp3.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: 791560ab56116084ebc209f37a62c59a +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Jungle.unity b/Assets/Scenes/Jungle.unity index 5afd3a7..0605e3b 100644 --- a/Assets/Scenes/Jungle.unity +++ b/Assets/Scenes/Jungle.unity @@ -3749,6 +3749,8 @@ GameObject: - component: {fileID: 519420031} - component: {fileID: 519420029} - component: {fileID: 519420033} + - component: {fileID: 519420034} + - component: {fileID: 519420035} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -3840,6 +3842,114 @@ MonoBehaviour: - {fileID: 5264188901624758220, guid: 1e6541a2de44a6f4e9ccc8bda54bbe60, type: 3} - {fileID: 3374466305813530289, guid: 0262f96f42c6aeb4684f54ead0bc9bcd, type: 3} - {fileID: 8896288112839863083, guid: 97a792faae28dc44395a47b01d479474, type: 3} +--- !u!114 &519420034 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 519420028} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8b7601b2105f8e449902982334da1552, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!82 &519420035 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 519420028} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 0} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + 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!1 &522725465 GameObject: m_ObjectHideFlags: 0 @@ -13112,6 +13222,7 @@ MonoBehaviour: groundCheckPoint1: {fileID: 0} groundCheckPoint2: {fileID: 0} invulnTime: 0 + hangTime: 0 stats: maxHealth: 0 speedMultiplier: 0 @@ -326791,6 +326902,7 @@ MonoBehaviour: groundCheckPoint1: {fileID: 0} groundCheckPoint2: {fileID: 0} invulnTime: 0 + hangTime: 0 stats: maxHealth: 0 speedMultiplier: 0 @@ -326820,6 +326932,7 @@ MonoBehaviour: groundCheckPoint1: {fileID: 0} groundCheckPoint2: {fileID: 0} invulnTime: 0 + hangTime: 0 stats: maxHealth: 0 speedMultiplier: 0 @@ -327323,6 +327436,7 @@ MonoBehaviour: groundCheckPoint1: {fileID: 0} groundCheckPoint2: {fileID: 0} invulnTime: 0 + hangTime: 0 stats: maxHealth: 0 speedMultiplier: 0 diff --git a/Assets/Scripts/Actors/Player.cs b/Assets/Scripts/Actors/Player.cs index 589d661..6201cad 100644 --- a/Assets/Scripts/Actors/Player.cs +++ b/Assets/Scripts/Actors/Player.cs @@ -78,6 +78,7 @@ namespace MontanaJohns.Actors protected void Fire() { Instantiate(projectilePrefab, firePoint.position, firePoint.rotation); + SoundManager.PlaySound("Gunshot"); } } } \ No newline at end of file diff --git a/Assets/Scripts/SoundManager.cs b/Assets/Scripts/SoundManager.cs new file mode 100644 index 0000000..128f41c --- /dev/null +++ b/Assets/Scripts/SoundManager.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SoundManager : MonoBehaviour +{ + static AudioSource audioSrc; + + private void Start() + { + audioSrc = GetComponent(); + } + + public static void PlaySound(string soundeffect) + { + audioSrc.PlayOneShot(Resources.Load($"SoundEffects/{soundeffect}")); + } +} diff --git a/Assets/Scripts/SoundManager.cs.meta b/Assets/Scripts/SoundManager.cs.meta new file mode 100644 index 0000000..c06b24e --- /dev/null +++ b/Assets/Scripts/SoundManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8b7601b2105f8e449902982334da1552 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- cgit v1.2.3-70-g09d2