diff --git a/Assets/Audio/SFX/shoot.wav b/Assets/Audio/SFX/shoot.wav new file mode 100644 index 0000000..15bf712 Binary files /dev/null and b/Assets/Audio/SFX/shoot.wav differ diff --git a/Assets/Audio/SFX/shoot.wav.meta b/Assets/Audio/SFX/shoot.wav.meta new file mode 100644 index 0000000..a7f9f8d --- /dev/null +++ b/Assets/Audio/SFX/shoot.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 57e6ff823fc6f704f9d71aed80db932f +AudioImporter: + externalObjects: {} + serializedVersion: 8 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/MyFactory.unity b/Assets/Scenes/MyFactory.unity index 584812f..72e5a87 100644 --- a/Assets/Scenes/MyFactory.unity +++ b/Assets/Scenes/MyFactory.unity @@ -3375,7 +3375,10 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 4210100720165400533, guid: 87e308cb23eea97419b3c2623d8bb3fa, type: 3} + insertIndex: -1 + addedObject: {fileID: 1834216786} m_SourcePrefab: {fileID: 100100000, guid: 87e308cb23eea97419b3c2623d8bb3fa, type: 3} --- !u!4 &253752627 stripped Transform: @@ -10118,6 +10121,108 @@ Transform: m_CorrespondingSourceObject: {fileID: 438488, guid: edd7bb53fcff5a84cb4228b91cdd3165, type: 3} m_PrefabInstance: {fileID: 810837519} m_PrefabAsset: {fileID: 0} +--- !u!1 &816325328 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 1717954561962503725, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3} + m_PrefabInstance: {fileID: 1461267492} + m_PrefabAsset: {fileID: 0} +--- !u!82 &816325335 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 816325328} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 0} + m_Resource: {fileID: 0} + m_PlayOnAwake: 0 + 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!1001 &816396565 PrefabInstance: m_ObjectHideFlags: 0 @@ -19901,7 +20006,10 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 1670256625, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3} insertIndex: -1 addedObject: {fileID: 253752627} - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 1717954561962503725, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3} + insertIndex: -1 + addedObject: {fileID: 816325335} m_SourcePrefab: {fileID: 100100000, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3} --- !u!4 &1461267493 stripped Transform: @@ -26112,6 +26220,26 @@ MonoBehaviour: m_Teleporting: m_PersistentCalls: m_Calls: [] +--- !u!1 &1834216785 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 4210100720165400533, guid: 87e308cb23eea97419b3c2623d8bb3fa, type: 3} + m_PrefabInstance: {fileID: 253752626} + m_PrefabAsset: {fileID: 0} +--- !u!114 &1834216786 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1834216785} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 200aefe84ef30164e840f8cb581b9308, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::GunController + rightTriggerAction: {fileID: 83097790271614945, guid: c348712bda248c246b8c49b3db54643f, type: 3} + audioSource: {fileID: 816325335} + triggerSoundEffect: {fileID: 8300000, guid: 57e6ff823fc6f704f9d71aed80db932f, type: 3} --- !u!1001 &1837025048 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/GunController.cs b/Assets/Scripts/GunController.cs new file mode 100644 index 0000000..f94eb08 --- /dev/null +++ b/Assets/Scripts/GunController.cs @@ -0,0 +1,34 @@ +using UnityEngine; +using UnityEngine.InputSystem; + +public class GunController : MonoBehaviour +{ + [SerializeField] private InputActionReference rightTriggerAction; + + [Header("Audio")] + [SerializeField] private AudioSource audioSource; + [SerializeField] private AudioClip triggerSoundEffect; + + private void OnEnable() + { + rightTriggerAction.action.Enable(); + rightTriggerAction.action.performed += OnTriggerPressed; + } + + private void OnDisable() + { + rightTriggerAction.action.performed -= OnTriggerPressed; + rightTriggerAction.action.Disable(); + } + + private void OnTriggerPressed(InputAction.CallbackContext context) + { + HandleShoot(); + } + + private void HandleShoot() + { + Debug.Log("Shoot!"); + audioSource.PlayOneShot(triggerSoundEffect); + } +} diff --git a/Assets/Scripts/GunController.cs.meta b/Assets/Scripts/GunController.cs.meta new file mode 100644 index 0000000..df4118f --- /dev/null +++ b/Assets/Scripts/GunController.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 200aefe84ef30164e840f8cb581b9308 \ No newline at end of file