From 69c98e9a8dd6c615dec98a89656ebaac9b93e5b3 Mon Sep 17 00:00:00 2001 From: cyndrdev Date: Mon, 17 May 2021 14:31:13 +0100 Subject: [PATCH] positional sounds pass --- game/Assets/Prefabs/Cameras.prefab | 47 ++++++++++++------- .../Assets/Scripts/Dialogue/DialogueSystem.cs | 8 +++- .../Dialogue/ScriptedDialogueTrigger.cs | 11 +++-- .../Assets/Scripts/Player/PlayerController.cs | 25 ++++++++-- game/FMOD Project/Build/Desktop/Master.bank | 4 +- game/FMOD Project/Build/Desktop/SFX.bank | 4 +- game/FMOD Project/Build/Desktop/VO.bank | 4 +- ...{886404c3-0312-4dc8-af6f-46f6ff1ed7a1}.xml | 8 +++- 8 files changed, 77 insertions(+), 34 deletions(-) diff --git a/game/Assets/Prefabs/Cameras.prefab b/game/Assets/Prefabs/Cameras.prefab index f9b01db..bab13f0 100644 --- a/game/Assets/Prefabs/Cameras.prefab +++ b/game/Assets/Prefabs/Cameras.prefab @@ -26,8 +26,8 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2832368838255871049} - m_LocalRotation: {x: 0.2294522, y: 0.04979975, z: -0.011756138, w: 0.9719741} - m_LocalPosition: {x: -0.039340973, y: 0.2522471, z: -2.719612} + m_LocalRotation: {x: -0.0981706, y: -0.8403349, z: -0.5077412, w: 0.16247682} + m_LocalPosition: {x: 0.06260109, y: -1.2571502, z: 0.0135195255} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 5661344206969957946} @@ -168,6 +168,7 @@ GameObject: - component: {fileID: 5661344207112327337} - component: {fileID: 5661344207112327338} - component: {fileID: 8137033370021049976} + - component: {fileID: 8846952043387883595} m_Layer: 0 m_Name: Main_Camera m_TagString: MainCamera @@ -182,8 +183,8 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 5661344207112327339} - m_LocalRotation: {x: 0.2294522, y: 0.04979975, z: -0.011756138, w: 0.9719741} - m_LocalPosition: {x: -0.039340973, y: 0.2522471, z: -2.719612} + m_LocalRotation: {x: -0.0981706, y: -0.8403349, z: -0.5077412, w: 0.16247682} + m_LocalPosition: {x: 0.06260109, y: -1.2571502, z: 0.0135195255} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 5661344206969957946} @@ -214,7 +215,7 @@ Camera: height: 1 near clip plane: 0.1 far clip plane: 5000 - field of view: 50 + field of view: 60 orthographic: 0 orthographic size: 5 m_Depth: 0 @@ -318,6 +319,20 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9d54716c6690d97469638748463784b8, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &8846952043387883595 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5661344207112327339} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 86c6556701af9e04380698b89f691b6e, type: 3} + m_Name: + m_EditorClassIdentifier: + attenuationObject: {fileID: 0} + ListenerNumber: -1 --- !u!1 &5661344207311831626 GameObject: m_ObjectHideFlags: 0 @@ -378,7 +393,7 @@ MonoBehaviour: m_LookAt: {fileID: 0} m_Follow: {fileID: 0} m_Lens: - FieldOfView: 50 + FieldOfView: 60 OrthographicSize: 10 NearClipPlane: 0.1 FarClipPlane: 5000 @@ -452,7 +467,7 @@ MonoBehaviour: m_LookAt: {fileID: 0} m_Follow: {fileID: 0} m_Lens: - FieldOfView: 50 + FieldOfView: 60 OrthographicSize: 10 NearClipPlane: 0.1 FarClipPlane: 5000 @@ -524,7 +539,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_BindingMode: 4 - m_FollowOffset: {x: 0, y: 1, z: -2} + m_FollowOffset: {x: 0, y: 0.5, z: -0.8} m_XDamping: 0.1 m_YDamping: 0.1 m_ZDamping: 0.1 @@ -534,7 +549,7 @@ MonoBehaviour: m_RollDamping: 0 m_AngularDamping: 0 m_Heading: - m_Definition: 2 + m_Definition: 1 m_VelocityFilterStrength: 4 m_Bias: 0 m_RecenterToTargetHeading: @@ -650,7 +665,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_BindingMode: 4 - m_FollowOffset: {x: 0, y: 1, z: -2} + m_FollowOffset: {x: 0, y: 0.5, z: -0.8} m_XDamping: 0.25 m_YDamping: 0.5 m_ZDamping: 0.25 @@ -660,7 +675,7 @@ MonoBehaviour: m_RollDamping: 0 m_AngularDamping: 0 m_Heading: - m_Definition: 2 + m_Definition: 1 m_VelocityFilterStrength: 4 m_Bias: 0 m_RecenterToTargetHeading: @@ -747,8 +762,8 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 5661344207789115490} - m_LocalRotation: {x: 0.22945215, y: 0.04979975, z: -0.011756136, w: 0.9719741} - m_LocalPosition: {x: 0.4574869, y: -0.86750305, z: -1.2498176} + m_LocalRotation: {x: 0.0981706, y: 0.8403349, z: 0.5077412, w: -0.16247682} + m_LocalPosition: {x: 0.06260109, y: -1.2571502, z: 0.0135195255} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 5661344207439169721} @@ -1033,7 +1048,7 @@ MonoBehaviour: m_LookAt: {fileID: 0} m_Follow: {fileID: 0} m_Lens: - FieldOfView: 50 + FieldOfView: 60 OrthographicSize: 10 NearClipPlane: 0.1 FarClipPlane: 5000 @@ -1105,7 +1120,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_BindingMode: 4 - m_FollowOffset: {x: 0, y: 1, z: -2} + m_FollowOffset: {x: 0, y: 0.5, z: -0.8} m_XDamping: 0.5 m_YDamping: 0.5 m_ZDamping: 0.5 @@ -1115,7 +1130,7 @@ MonoBehaviour: m_RollDamping: 0 m_AngularDamping: 0 m_Heading: - m_Definition: 2 + m_Definition: 1 m_VelocityFilterStrength: 4 m_Bias: 0 m_RecenterToTargetHeading: diff --git a/game/Assets/Scripts/Dialogue/DialogueSystem.cs b/game/Assets/Scripts/Dialogue/DialogueSystem.cs index 0b659af..b7d9f0d 100644 --- a/game/Assets/Scripts/Dialogue/DialogueSystem.cs +++ b/game/Assets/Scripts/Dialogue/DialogueSystem.cs @@ -118,11 +118,11 @@ public partial class DialogueSystem : ScriptableObject public float GetLineDuration(string key) => _settings.GetDialogueClip(key).length; - public void PlayLineBaz(string key) => PlayLine(ref _bazInstance, _settings.BazDialogueKey, key); + public void PlayLineBaz(string key, Transform bazObject) => PlayLine(ref _bazInstance, _settings.BazDialogueKey, key, speakerObject: bazObject); public void PlayLineRadio(string key) => PlayLine(ref _radioInstance, _settings.RadioDialogueKey, key); // noRepeat locks this key off from further use. further attempts to use the key will be discarded - private void PlayLine(ref EventInstance eventInstance, string speakerKey, string key, bool noRepeat = true) + private void PlayLine(ref EventInstance eventInstance, string speakerKey, string key, bool noRepeat = true, Transform speakerObject = null ) { if (noRepeat) { @@ -152,6 +152,10 @@ public partial class DialogueSystem : ScriptableObject dl.duration = clip.length; eventInstance.setCallback(_dialogueCallback); + if ( speakerObject ) + { + RuntimeManager.AttachInstanceToGameObject( eventInstance, speakerObject, (Rigidbody) null ); + } eventInstance.start(); onDialogueLine?.Invoke(this, dl); diff --git a/game/Assets/Scripts/Dialogue/ScriptedDialogueTrigger.cs b/game/Assets/Scripts/Dialogue/ScriptedDialogueTrigger.cs index 604663e..d84b981 100644 --- a/game/Assets/Scripts/Dialogue/ScriptedDialogueTrigger.cs +++ b/game/Assets/Scripts/Dialogue/ScriptedDialogueTrigger.cs @@ -17,6 +17,7 @@ public class ScriptedDialogueTrigger : MonoBehaviour [SerializeField] private DialogueSystem _dialogue; [SerializeField] private Speaker _speaker = Speaker.Radio; + [SerializeField] private Transform _speakerTransform; [Obsolete] [SerializeField] private string _key; @@ -54,7 +55,7 @@ public class ScriptedDialogueTrigger : MonoBehaviour if (_keys.Length == 0) { - PlayLine(_key); + PlayLine(_key, _speakerTransform); } else { @@ -68,7 +69,7 @@ public class ScriptedDialogueTrigger : MonoBehaviour var elapsed = 0f; // play first line - PlayLine(_keys[0]); + PlayLine(_keys[0], _speakerTransform); while (idx < _keys.Length) { @@ -77,14 +78,14 @@ public class ScriptedDialogueTrigger : MonoBehaviour { elapsed = 0; idx++; - PlayLine(_keys[idx]); + PlayLine(_keys[idx], _speakerTransform); } yield return null; } } - private void PlayLine(string key) + private void PlayLine(string key, Transform speakerObject) { switch (_speaker) { @@ -93,7 +94,7 @@ public class ScriptedDialogueTrigger : MonoBehaviour break; case Speaker.Baz: - _dialogue.PlayLineBaz(key); + _dialogue.PlayLineBaz(key, speakerObject); break; } } diff --git a/game/Assets/Scripts/Player/PlayerController.cs b/game/Assets/Scripts/Player/PlayerController.cs index c9ce84a..e68ac16 100644 --- a/game/Assets/Scripts/Player/PlayerController.cs +++ b/game/Assets/Scripts/Player/PlayerController.cs @@ -3,8 +3,11 @@ using UnityEngine; using NaughtyAttributes; using Ktyl.Util; using System.Collections; +using FMOD; +using FMOD.Studio; using FMODUnity; using UnityEngine.UI; +using STOP_MODE = FMOD.Studio.STOP_MODE; public class PlayerController : MonoBehaviour { @@ -96,14 +99,17 @@ public class PlayerController : MonoBehaviour [SerializeField] [FMODUnity.EventRef] private string _freezeSfx; + private EventInstance _freezeInstance; [SerializeField] [FMODUnity.EventRef] private string _blinkSfx; + private EventInstance _blinkInstance; [SerializeField] [FMODUnity.EventRef] private string _boostSfx; + private EventInstance _boostInstance; private enum JumpState { @@ -116,10 +122,21 @@ public class PlayerController : MonoBehaviour [ShowNonSerializedField] private JumpState _jumpState; - + private void Start() { _freezeVfx.SetActive( false ); + + _freezeInstance = RuntimeManager.CreateInstance( _freezeSfx ); + _blinkInstance = RuntimeManager.CreateInstance( _blinkSfx ); + _boostInstance = RuntimeManager.CreateInstance( _boostSfx ); + } + + private void PlayPlayerSFX( EventInstance instance ) + { + instance.stop(STOP_MODE.IMMEDIATE); + instance.start(); + RuntimeManager.AttachInstanceToGameObject( instance, transform, (Rigidbody)null ); } private Color GetDebugColor() @@ -184,7 +201,7 @@ public class PlayerController : MonoBehaviour Vector2 blinkDirection = Vector2.up.Rotate( -_lookAngle ); _overrideDelta += blinkDirection * _movementSettings.BlinkDistance; _surfVelocity += blinkDirection * _movementSettings.BlinkVelocity; - FMODUnity.RuntimeManager.PlayOneShot( _blinkSfx ); + PlayPlayerSFX( _blinkInstance ); } } @@ -196,7 +213,7 @@ public class PlayerController : MonoBehaviour _powers.Freeze.Consume(); objectTimeScale.Value = 0f; _freezeVfx.SetActive( true ); - FMODUnity.RuntimeManager.PlayOneShot( _freezeSfx ); + PlayPlayerSFX( _freezeInstance ); } if ( _powers.Freeze.timeSinceConsume > frozenTime && TimeIsFrozen ) @@ -259,7 +276,7 @@ public class PlayerController : MonoBehaviour _yVelocity = _movementSettings.MinBoostVelocity; } - RuntimeManager.PlayOneShot(_boostSfx); + PlayPlayerSFX( _boostInstance ); } break; diff --git a/game/FMOD Project/Build/Desktop/Master.bank b/game/FMOD Project/Build/Desktop/Master.bank index 6ae4995..6f4f6bd 100644 --- a/game/FMOD Project/Build/Desktop/Master.bank +++ b/game/FMOD Project/Build/Desktop/Master.bank @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:207c745d716f984fe8387050010ff71df5a3488948e0dade35c7e53b3df0ef62 -size 12376 +oid sha256:d1586f2a294623ffee33ae3161272da99ac51448bbeb73698bd4e157f366323f +size 12640 diff --git a/game/FMOD Project/Build/Desktop/SFX.bank b/game/FMOD Project/Build/Desktop/SFX.bank index c01ea94..72fb24e 100644 --- a/game/FMOD Project/Build/Desktop/SFX.bank +++ b/game/FMOD Project/Build/Desktop/SFX.bank @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:612415da1c2cb13919cb8158dfd14555658ab783819f1f04febd336bfbc1b9fc -size 4169056 +oid sha256:1b3b3f495fb354144cfdca41f82fcad42d91515fb17321bdb911e110713a5320 +size 4169312 diff --git a/game/FMOD Project/Build/Desktop/VO.bank b/game/FMOD Project/Build/Desktop/VO.bank index a5f4ca6..2e27e7d 100644 --- a/game/FMOD Project/Build/Desktop/VO.bank +++ b/game/FMOD Project/Build/Desktop/VO.bank @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e86bfaec5dea2bbb732ed645333885d8d779464703a944b2f80467536e2d9e02 -size 2945760 +oid sha256:c36c5658dbe443f0e036b758a8ceb971072ff7eec385f8a7f7fd6ee25884db97 +size 2946016 diff --git a/game/FMOD Project/Metadata/Event/{886404c3-0312-4dc8-af6f-46f6ff1ed7a1}.xml b/game/FMOD Project/Metadata/Event/{886404c3-0312-4dc8-af6f-46f6ff1ed7a1}.xml index edf7808..e596095 100644 --- a/game/FMOD Project/Metadata/Event/{886404c3-0312-4dc8-af6f-46f6ff1ed7a1}.xml +++ b/game/FMOD Project/Metadata/Event/{886404c3-0312-4dc8-af6f-46f6ff1ed7a1}.xml @@ -26,7 +26,7 @@ https://soundcloud.com/nasa Baz Dialogue Line - 1 + 2 {aacc9c7d-10bf-4006-bcdd-9a56dd0d03e4} @@ -157,6 +157,7 @@ https://soundcloud.com/nasa {1d02e252-40d7-45a2-918e-171d67ad50a3} {aa3974fd-9122-4ef6-91bd-d1cbbd5d9c18} {2cf8ef76-9df1-4b8a-905e-279aeec02cd2} + {0d1e768d-81c4-439c-8703-536561e3a8d4} @@ -189,6 +190,11 @@ https://soundcloud.com/nasa + + + 3.4000001 + + true