На погружение добавлен фильтр низких частот
This commit is contained in:
parent
725c623031
commit
e433f66394
@ -35,6 +35,24 @@ AudioMixerEffectController:
|
||||
m_SendTarget: {fileID: 0}
|
||||
m_EnableWetMix: 0
|
||||
m_Bypass: 0
|
||||
--- !u!244 &-8209106451493698042
|
||||
AudioMixerEffectController:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_EffectID: 68f159d1326f3e4419d39d6ab8970083
|
||||
m_EffectName: Lowpass
|
||||
m_MixLevel: fb30e5f59ffe4f24ba36f5d5f38ebbe2
|
||||
m_Parameters:
|
||||
- m_ParameterName: Cutoff freq
|
||||
m_GUID: ad4c94e3ff81f524fb26fd97381e6594
|
||||
- m_ParameterName: Resonance
|
||||
m_GUID: c12c8b0f7e4811d40aa4b4c1f898555e
|
||||
m_SendTarget: {fileID: 0}
|
||||
m_EnableWetMix: 0
|
||||
m_Bypass: 0
|
||||
--- !u!243 &-7085291298577199494
|
||||
AudioMixerGroupController:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -54,6 +72,24 @@ AudioMixerGroupController:
|
||||
m_Mute: 0
|
||||
m_Solo: 0
|
||||
m_BypassEffects: 0
|
||||
--- !u!244 &-6896905097741947499
|
||||
AudioMixerEffectController:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_EffectID: 4abcf396f85cdf94482a8c0e15e37c63
|
||||
m_EffectName: Lowpass
|
||||
m_MixLevel: 17c751ea1878ab74d9610836cb282f89
|
||||
m_Parameters:
|
||||
- m_ParameterName: Cutoff freq
|
||||
m_GUID: 56a5d179a962dda42881afc4f6ce6146
|
||||
- m_ParameterName: Resonance
|
||||
m_GUID: d7d1d8057ff372d4f95aeeee02ceb8fc
|
||||
m_SendTarget: {fileID: 0}
|
||||
m_EnableWetMix: 0
|
||||
m_Bypass: 0
|
||||
--- !u!244 &-6583804337637792457
|
||||
AudioMixerEffectController:
|
||||
m_ObjectHideFlags: 3
|
||||
@ -161,6 +197,10 @@ AudioMixerController:
|
||||
m_ExposedParameters:
|
||||
- guid: 2bf7426a92fadf74b898c7b9b855be44
|
||||
name: GameplayVolume
|
||||
- guid: ad4c94e3ff81f524fb26fd97381e6594
|
||||
name: LowpassCutoffFreq
|
||||
- guid: c12c8b0f7e4811d40aa4b4c1f898555e
|
||||
name: LowpassResonance
|
||||
- guid: 6c9bd92bd4093ba4095c7091f5b2026c
|
||||
name: MasterVolume
|
||||
- guid: 0e34ffab23f3fff4fbdac96a3f4352f4
|
||||
@ -224,6 +264,8 @@ AudioMixerSnapshotController:
|
||||
m_SnapshotID: 61b51ab759636dd4c9a6ea14d1769e9b
|
||||
m_FloatValues:
|
||||
2f4861e1d6570594589f1a3d3303c4ea: 0
|
||||
d7d1d8057ff372d4f95aeeee02ceb8fc: 1
|
||||
56a5d179a962dda42881afc4f6ce6146: 22000
|
||||
6c9bd92bd4093ba4095c7091f5b2026c: -0.17160717
|
||||
0e34ffab23f3fff4fbdac96a3f4352f4: -0.27209988
|
||||
34ee8d8c629396840bda87fa664de7a0: -0.18620056
|
||||
@ -260,6 +302,7 @@ AudioMixerGroupController:
|
||||
m_Send: 00000000000000000000000000000000
|
||||
m_Effects:
|
||||
- {fileID: -4383131060249931627}
|
||||
- {fileID: -8209106451493698042}
|
||||
m_UserColorIndex: 0
|
||||
m_Mute: 0
|
||||
m_Solo: 0
|
||||
@ -317,6 +360,7 @@ AudioMixerGroupController:
|
||||
m_Send: 00000000000000000000000000000000
|
||||
m_Effects:
|
||||
- {fileID: -6583804337637792457}
|
||||
- {fileID: -6896905097741947499}
|
||||
m_UserColorIndex: 0
|
||||
m_Mute: 0
|
||||
m_Solo: 0
|
||||
|
||||
@ -148,7 +148,7 @@ Material:
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 0}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 0}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 0.3}
|
||||
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
|
||||
@ -242,7 +242,7 @@ AudioSource:
|
||||
m_audioClip: {fileID: 0}
|
||||
m_Resource: {fileID: 8300000, guid: 6c87789de020fec43985abd1c1079ac0, type: 3}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Volume: 0.3
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
@ -251,9 +251,9 @@ AudioSource:
|
||||
Priority: 128
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 500
|
||||
MaxDistance: 2000
|
||||
Pan2D: 0
|
||||
rolloffMode: 0
|
||||
rolloffMode: 1
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
@ -286,7 +286,7 @@ AudioSource:
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
|
||||
@ -244,18 +244,18 @@ AudioSource:
|
||||
m_audioClip: {fileID: 0}
|
||||
m_Resource: {fileID: 8300000, guid: 6c87789de020fec43985abd1c1079ac0, type: 3}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Volume: 0.3
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 128
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 500
|
||||
DopplerLevel: 0.81
|
||||
MinDistance: 0
|
||||
MaxDistance: 2000
|
||||
Pan2D: 0
|
||||
rolloffMode: 0
|
||||
rolloffMode: 1
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
@ -288,7 +288,7 @@ AudioSource:
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
|
||||
@ -4843,6 +4843,7 @@ Canvas:
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 1
|
||||
m_UseReflectionProbes: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@ -11710,7 +11711,7 @@ Light:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 816115653}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 12
|
||||
serializedVersion: 13
|
||||
m_Type: 1
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Intensity: 1.2
|
||||
@ -11762,7 +11763,7 @@ Light:
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_UseViewFrustumForShadowCasterCull: 1
|
||||
m_ForceVisible: 0
|
||||
m_ShadowRadius: 0
|
||||
m_ShapeRadius: 0
|
||||
m_ShadowAngle: 40
|
||||
m_LightUnit: 1
|
||||
m_LuxAtDistance: 1
|
||||
@ -21172,7 +21173,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 1, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -1.5}
|
||||
m_SizeDelta: {x: 36, y: -11}
|
||||
m_SizeDelta: {x: 50, y: -11}
|
||||
m_Pivot: {x: 1, y: 0.5}
|
||||
--- !u!114 &1153696197
|
||||
MonoBehaviour:
|
||||
@ -30579,6 +30580,7 @@ GameObject:
|
||||
- component: {fileID: 1623199038}
|
||||
- component: {fileID: 1623199039}
|
||||
- component: {fileID: 1623199036}
|
||||
- component: {fileID: 1623199040}
|
||||
m_Layer: 10
|
||||
m_Name: Player
|
||||
m_TagString: Untagged
|
||||
@ -30788,6 +30790,25 @@ MonoBehaviour:
|
||||
bubbleParticles:
|
||||
- {fileID: 848010580}
|
||||
- {fileID: 1377478998}
|
||||
--- !u!114 &1623199040
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1623199033}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: c53156e315745694a807ae6763918161, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::MixerController
|
||||
mixer: {fileID: 24100000, guid: 9e60f4c98f741874887713174defa070, type: 2}
|
||||
upCutoff: 22000
|
||||
upResonance: 1
|
||||
upSpeed: 0.3
|
||||
downCutoff: 1500
|
||||
downResonance: 1.5
|
||||
downSpeed: 0.7
|
||||
--- !u!1 &1624902159
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -33565,6 +33586,7 @@ Canvas:
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_UseReflectionProbes: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
@ -36193,7 +36215,7 @@ Light:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2054573125}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 12
|
||||
serializedVersion: 13
|
||||
m_Type: 1
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Intensity: 0.1
|
||||
@ -36245,7 +36267,7 @@ Light:
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_UseViewFrustumForShadowCasterCull: 1
|
||||
m_ForceVisible: 0
|
||||
m_ShadowRadius: 0
|
||||
m_ShapeRadius: 0
|
||||
m_ShadowAngle: 10
|
||||
m_LightUnit: 1
|
||||
m_LuxAtDistance: 1
|
||||
@ -37380,6 +37402,7 @@ MonoBehaviour:
|
||||
endgameAnimations1: {fileID: 1459415913}
|
||||
cameraShaker: {fileID: 280953195}
|
||||
airDropManager: {fileID: 1005655280}
|
||||
mixerController: {fileID: 1623199040}
|
||||
--- !u!4 &2124126987
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -27,6 +27,8 @@ public class GameplayBootstrap : MonoBehaviour
|
||||
[SerializeField] private CameraShaker cameraShaker;
|
||||
[SerializeField] private AirDropManager airDropManager;
|
||||
|
||||
[SerializeField] MixerController mixerController;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (!BootstrapperState.MainBootstraped)
|
||||
@ -63,5 +65,6 @@ public class GameplayBootstrap : MonoBehaviour
|
||||
|
||||
airDropManager.Init(PlayerTransform.gameObject);
|
||||
|
||||
mixerController.Init();
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@ using UnityEngine;
|
||||
public class PlayerDiveSystem : MonoBehaviour
|
||||
{
|
||||
public event Action Surfaced;
|
||||
public event Action Dived;
|
||||
|
||||
|
||||
[Header("Настройки погружения")]
|
||||
[SerializeField] private Transform UpPoint;
|
||||
@ -26,7 +28,8 @@ public class PlayerDiveSystem : MonoBehaviour
|
||||
private bool forceMoveUp = false;
|
||||
private float lastSurfacedTime = -Mathf.Infinity; // Время последнего вызова Surfaced
|
||||
private bool wasUnderPressure = false;
|
||||
private bool wasMovingUp = false;
|
||||
private bool wasMovingUp = false;
|
||||
private bool down = false;
|
||||
|
||||
public float PressurePercent { get; private set; }
|
||||
public float DepthPercent => (UpPoint.position.y - transform.position.y) / totalHeight;
|
||||
@ -88,19 +91,32 @@ public class PlayerDiveSystem : MonoBehaviour
|
||||
|
||||
private void TriggerSurfaced()
|
||||
{
|
||||
down = false;
|
||||
Surfaced?.Invoke();
|
||||
lastSurfacedTime = Time.time;
|
||||
}
|
||||
|
||||
private void TriggerDived()
|
||||
{
|
||||
if (!down)
|
||||
{
|
||||
down = true;
|
||||
Dived?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessPressure()
|
||||
{
|
||||
if (DepthPercent > DepthPercentToStartPressure)
|
||||
{
|
||||
AddPressure();
|
||||
TriggerDived();
|
||||
foreach(var bubble in bubbleParticles)
|
||||
{
|
||||
if(!bubble.isPlaying) bubble.Play();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
86
Assets/Scripts/MixerController.cs
Normal file
86
Assets/Scripts/MixerController.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
public class MixerController : MonoBehaviour
|
||||
{
|
||||
const string LowpassCutoffFreq = "LowpassCutoffFreq";
|
||||
const string LowpassResonance = "LowpassResonance";
|
||||
|
||||
[SerializeField] AudioMixer mixer;
|
||||
|
||||
[Header("Фильтры над водой")]
|
||||
[SerializeField] float upCutoff = 22000f;
|
||||
[SerializeField] float upResonance = 1f;
|
||||
[SerializeField] float upSpeed = 0.5f;
|
||||
|
||||
[Header("Фильтры под водой")]
|
||||
[SerializeField] float downCutoff = 1000f;
|
||||
[SerializeField] float downResonance = 2f;
|
||||
[SerializeField] float downSpeed = 1.5f;
|
||||
|
||||
private CancellationTokenSource cts;
|
||||
private bool initialized = false;
|
||||
private float t = 1;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
G.PlayerStateModel.PlayerComponent.DiveSystem.Dived += DiveSystem_Dived;
|
||||
G.PlayerStateModel.PlayerComponent.DiveSystem.Surfaced += DiveSystem_Surfaced;
|
||||
|
||||
mixer.SetFloat(LowpassCutoffFreq, upCutoff);
|
||||
mixer.SetFloat(LowpassResonance, upResonance);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
private void DiveSystem_Surfaced() => SetUnderwater(goingDown: false);
|
||||
private void DiveSystem_Dived() => SetUnderwater(goingDown: true);
|
||||
|
||||
public void SetUnderwater(bool goingDown)
|
||||
{
|
||||
|
||||
cts?.Cancel();
|
||||
cts?.Dispose();
|
||||
cts = new();
|
||||
|
||||
var speed = goingDown ? downSpeed : upSpeed;
|
||||
SetFiltersAsync(goingDown, speed, cts.Token).Forget();
|
||||
}
|
||||
|
||||
private async UniTask SetFiltersAsync(bool goingDown, float speed, CancellationToken token)
|
||||
{
|
||||
float targetT = goingDown ? 0 : 1;
|
||||
while(t != targetT && !token.IsCancellationRequested)
|
||||
{
|
||||
float delta = Time.deltaTime * speed;
|
||||
t = Mathf.MoveTowards(t, targetT, delta);
|
||||
|
||||
var cutoff = Mathf.Lerp(downCutoff, upCutoff, t);
|
||||
var resonance = Mathf.Lerp(downResonance, upResonance, t);
|
||||
|
||||
mixer.SetFloat(LowpassCutoffFreq, cutoff);
|
||||
mixer.SetFloat(LowpassResonance, resonance);
|
||||
|
||||
await UniTask.Yield(PlayerLoopTiming.Update, token);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
cts?.Cancel();
|
||||
cts?.Dispose();
|
||||
|
||||
mixer.SetFloat(LowpassCutoffFreq, upCutoff);
|
||||
mixer.SetFloat(LowpassResonance, upResonance);
|
||||
|
||||
if(initialized)
|
||||
{
|
||||
G.PlayerStateModel.PlayerComponent.DiveSystem.Dived -= DiveSystem_Dived;
|
||||
G.PlayerStateModel.PlayerComponent.DiveSystem.Surfaced -= DiveSystem_Surfaced;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
2
Assets/Scripts/MixerController.cs.meta
Normal file
2
Assets/Scripts/MixerController.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c53156e315745694a807ae6763918161
|
||||
File diff suppressed because one or more lines are too long
@ -144,9 +144,7 @@ PlayerSettings:
|
||||
visionOSBundleVersion: 1.0
|
||||
tvOSBundleVersion: 1.0
|
||||
bundleVersion: 0.1.0
|
||||
preloadedAssets:
|
||||
- {fileID: 5922519487378018138, guid: 2b45221522efe2d44a45c72101437489, type: 2}
|
||||
- {fileID: 6533799398217704406, guid: 787733aa150d6364585ecc7d9f2deaee, type: 2}
|
||||
preloadedAssets: []
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
xboxOneDisableKinectGpuReservation: 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user