This commit is contained in:
Ferlat Thibaud
2026-03-27 16:36:18 +01:00
18 changed files with 503 additions and 40178 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,87 @@
using UnityEngine;
using System.Collections.Generic;
using AK.Wwise;
[RequireComponent(typeof(CharacterController))]
public class Audio_FootstepsController : MonoBehaviour
{
[System.Serializable]
public struct SurfaceMapping
{
public string tag;
public AK.Wwise.Switch wwiseSwitch;
}
[Header("Wwise Assets")]
public AK.Wwise.Event footstepEvent;
[Header("Surface Configuration")]
public List<SurfaceMapping> surfaces = new List<SurfaceMapping>();
public AK.Wwise.Switch defaultSwitch;
[Header("Movement Settings")]
[SerializeField] private float _stepInterval = 0.5f;
[SerializeField] private float _minVelocity = 0.3f;
[SerializeField] private float _rayDistance = 0.2f;
[SerializeField] private LayerMask _groundLayer;
private CharacterController _controller;
private float _timer;
private Dictionary<string, AK.Wwise.Switch> _surfaceCache;
void Awake()
{
_controller = GetComponent<CharacterController>();
_surfaceCache = new Dictionary<string, AK.Wwise.Switch>();
foreach (var mapping in surfaces)
{
if (!string.IsNullOrEmpty(mapping.tag))
{
_surfaceCache[mapping.tag.ToLower()] = mapping.wwiseSwitch;
}
}
}
void Update()
{
if (_controller.isGrounded && _controller.velocity.magnitude > _minVelocity)
{
_timer += Time.deltaTime;
if (_timer >= _stepInterval)
{
PlayFootstep();
_timer = 0f;
}
}
else
{
_timer = _stepInterval;
}
}
private void PlayFootstep()
{
RaycastHit hit;
if (Physics.Raycast(transform.position + Vector3.up * 0.1f, Vector3.down, out hit, _rayDistance, _groundLayer))
{
string currentTag = hit.collider.tag.ToLower();
if (_surfaceCache.TryGetValue(currentTag, out AK.Wwise.Switch targetSwitch))
{
targetSwitch.SetValue(gameObject);
// Debug.Log($"[Footsteps] Switch Wwise set on : {currentTag}");
}
else
{
defaultSwitch.SetValue(gameObject);
Debug.LogWarning($"[Footsteps] Tag '{currentTag}' inconnu. Utilisation du switch par défaut.");
}
footstepEvent.Post(gameObject);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5a11b07babb12d446a356745e7a37303
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 585ef86653ff8b34996821f778cfa782
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7b54f077b8751ef4fab18faa68deb555, type: 3}
m_Name: 022E15A9-DB2C-45F3-8D60-42B5972AD986
m_EditorClassIdentifier: AK.Wwise.Unity.API.WwiseTypes::WwiseSwitchReference
objectName: carpet
id: 2412606308
guid: 022E15A9-DB2C-45F3-8D60-42B5972AD986
WwiseSwitchGroupReference: {fileID: 11400000, guid: 7894acdae10032b4fa5eb169b135dab7, type: 2}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cba7dd3dc6dddc744b665136cf09f95f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7b54f077b8751ef4fab18faa68deb555, type: 3}
m_Name: 1B0178C8-ACAF-41A3-83AA-085C6045F07C
m_EditorClassIdentifier: AK.Wwise.Unity.API.WwiseTypes::WwiseSwitchReference
objectName: wood
id: 2058049674
guid: 1B0178C8-ACAF-41A3-83AA-085C6045F07C
WwiseSwitchGroupReference: {fileID: 11400000, guid: 7894acdae10032b4fa5eb169b135dab7, type: 2}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 90b25d313fd10fe4bb34ce68d987f60e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7b54f077b8751ef4fab18faa68deb555, type: 3}
m_Name: C2B3EAC0-49E1-4C4B-A47E-8667C7765937
m_EditorClassIdentifier: AK.Wwise.Unity.API.WwiseTypes::WwiseSwitchReference
objectName: stone
id: 1216965916
guid: C2B3EAC0-49E1-4C4B-A47E-8667C7765937
WwiseSwitchGroupReference: {fileID: 11400000, guid: 7894acdae10032b4fa5eb169b135dab7, type: 2}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cea23ef8af49aa54f9c3833465570bb2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 10d78c2f2a4c09a409f48d467acfee5f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cb51cd373049a214d85ff57cc88668be, type: 3}
m_Name: 8CACC1F3-9150-4639-BB38-0F00BB2E289F
m_EditorClassIdentifier: AK.Wwise.Unity.API.WwiseTypes::WwiseSwitchGroupReference
objectName: footstepsType
id: 520915638
guid: 8CACC1F3-9150-4639-BB38-0F00BB2E289F
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7894acdae10032b4fa5eb169b135dab7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
+4 -1
View File
@@ -3,7 +3,10 @@
--- !u!78 &1 --- !u!78 &1
TagManager: TagManager:
serializedVersion: 3 serializedVersion: 3
tags: [] tags:
- wood
- stone
- carpet
layers: layers:
- Default - Default
- TransparentFX - TransparentFX
@@ -14,10 +14,20 @@
</ReferenceList> </ReferenceList>
<ChildrenList> <ChildrenList>
<SwitchContainer Name="playerFootsteps" ID="{8D053102-F4D1-4230-A1E0-209A88B761EE}" ShortID="132412009"> <SwitchContainer Name="playerFootsteps" ID="{8D053102-F4D1-4230-A1E0-209A88B761EE}" ShortID="132412009">
<PropertyList>
<Property Name="Volume" Type="Real64">
<ValueList>
<Value>-12</Value>
</ValueList>
</Property>
</PropertyList>
<ReferenceList> <ReferenceList>
<Reference Name="Conversion"> <Reference Name="Conversion">
<ObjectRef Name="Default Conversion Settings" ID="{6D1B890C-9826-4384-BF07-C15223E9FB56}" WorkUnitID="{16AA8EB9-7498-45FF-B66E-783ABF47004A}"/> <ObjectRef Name="Default Conversion Settings" ID="{6D1B890C-9826-4384-BF07-C15223E9FB56}" WorkUnitID="{16AA8EB9-7498-45FF-B66E-783ABF47004A}"/>
</Reference> </Reference>
<Reference Name="DefaultSwitchOrState">
<ObjectRef Name="stone" ID="{C2B3EAC0-49E1-4C4B-A47E-8667C7765937}" WorkUnitID="{22AB7C3B-5222-4ACE-85EB-EEC2D48918E3}"/>
</Reference>
<Reference Name="OutputBus"> <Reference Name="OutputBus">
<ObjectRef Name="Main Audio Bus" ID="{1514A4D8-1DA6-412A-A17E-75CA0C2149F3}" WorkUnitID="{2098B74C-876E-4F52-B5FB-02CBA1A95394}"/> <ObjectRef Name="Main Audio Bus" ID="{1514A4D8-1DA6-412A-A17E-75CA0C2149F3}" WorkUnitID="{2098B74C-876E-4F52-B5FB-02CBA1A95394}"/>
</Reference> </Reference>
@@ -10,7 +10,7 @@
"Type": "Event", "Type": "Event",
"GUID": "{CA01D78F-151E-46B3-8B01-209B21D1DCAF}", "GUID": "{CA01D78F-151E-46B3-8B01-209B21D1DCAF}",
"Language": "SFX", "Language": "SFX",
"Hash": "{2A50C422-11B3-81C0-F409-FFD978682578}", "Hash": "{C10A53D7-643F-2311-886F-A09F827E760E}",
"ObjectPath": "Play_playerFootsteps", "ObjectPath": "Play_playerFootsteps",
"ShortName": "Play_playerFootsteps", "ShortName": "Play_playerFootsteps",
"Path": "Event/Play_playerFootsteps.bnk", "Path": "Event/Play_playerFootsteps.bnk",
@@ -342,7 +342,8 @@
"GroupType": "Switch", "GroupType": "Switch",
"GroupId": "520915638", "GroupId": "520915638",
"Id": "1216965916", "Id": "1216965916",
"GUID": "{C2B3EAC0-49E1-4C4B-A47E-8667C7765937}" "GUID": "{C2B3EAC0-49E1-4C4B-A47E-8667C7765937}",
"Default": "true"
}, },
"MediaRefs": [ "MediaRefs": [
{ {
@@ -450,6 +451,6 @@
] ]
} }
], ],
"FileHash": "{0063A3E3-3FFC-3515-E124-CE88EA4BB499}" "FileHash": "{8F74224C-06FA-22CB-2D34-E36294B27F31}"
} }
} }
@@ -1,5 +1,5 @@
Event ID Name Wwise Object Path Notes Event ID Name Wwise Object Path Notes
1805011878 Play_playerFootsteps \SFX\PLAYER\Play_playerFootsteps 1805011878 Play_playerFootsteps \SFX\Player\Play_playerFootsteps
Switch Group ID Name Wwise Object Path Notes Switch Group ID Name Wwise Object Path Notes
520915638 footstepsType \Player\Movmement\footstepsType 520915638 footstepsType \Player\Movmement\footstepsType