feat : gradual rtpc control prefab

This commit is contained in:
Hugo Le Bolloc'h
2026-04-04 14:14:11 +02:00
parent fef26f3790
commit 91f220f985
13 changed files with 826 additions and 2 deletions
@@ -33,4 +33,16 @@ public class Audio_MusicStateTrigger : MonoBehaviour
Audio_AudioManager.Instance?.SetWwiseMusicState(exitMusicState);
}
#if UNITY_EDITOR
private void OnDrawGizmos()
{
BoxCollider box = GetComponent<BoxCollider>();
Gizmos.matrix = transform.localToWorldMatrix;
Gizmos.color = new Color(0f, 1f, 0.5f, 0.25f);
Gizmos.DrawCube(box.center, box.size);
Gizmos.color = new Color(0f, 1f, 0.5f, 0.8f);
Gizmos.DrawWireCube(box.center, box.size);
}
#endif
}
@@ -0,0 +1,34 @@
using UnityEngine;
[RequireComponent(typeof(BoxCollider))]
public class Audio_RTPCZone : MonoBehaviour
{
[HideInInspector] public Audio_RTPCZoneManager manager;
private bool _triggered = false;
private void Awake()
{
GetComponent<BoxCollider>().isTrigger = true;
}
private void OnTriggerEnter(Collider other)
{
if (!other.CompareTag("Player")) return;
if (manager.oneShot && _triggered) return;
_triggered = true;
manager.OnZoneEntered();
}
#if UNITY_EDITOR
private void OnDrawGizmos()
{
BoxCollider box = GetComponent<BoxCollider>();
Gizmos.matrix = transform.localToWorldMatrix;
Gizmos.color = new Color(0f, 1f, 0.5f, 0.25f);
Gizmos.DrawCube(box.center, box.size);
Gizmos.color = new Color(0f, 1f, 0.5f, 0.8f);
Gizmos.DrawWireCube(box.center, box.size);
}
#endif
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 66b5d13a3d510664faf00b6012abbe32
@@ -0,0 +1,33 @@
using UnityEngine;
public class Audio_RTPCZoneManager : MonoBehaviour
{
[Header("Rtpc")]
public AK.Wwise.RTPC rtpc;
[Tooltip("Value added to the RTPC each time a zone is entered")]
public float valueIncrement = 1f;
[Tooltip("If true, each zone only triggers once per session")]
public bool oneShot = true;
[Header("Clamp")]
public float minValue = 0f;
public float maxValue = 10f;
private float _currentValue = 0f;
private void Start()
{
foreach (var zone in GetComponentsInChildren<Audio_RTPCZone>())
{
zone.manager = this;
}
}
public void OnZoneEntered()
{
_currentValue = Mathf.Clamp(_currentValue + valueIncrement, minValue, maxValue);
rtpc.SetGlobalValue(_currentValue);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 908b8bddba6d5d940b57c57ba1d2ec33