chore : change footsteps detection from tag to custom comp
This commit is contained in:
@@ -131,7 +131,6 @@ GameObject:
|
||||
- component: {fileID: 245714137}
|
||||
- component: {fileID: 245714136}
|
||||
- component: {fileID: 245714135}
|
||||
- component: {fileID: 245714139}
|
||||
m_Layer: 0
|
||||
m_Name: Plane (1)
|
||||
m_TagString: carpet
|
||||
@@ -233,24 +232,6 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &245714139
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 245714134}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 380f7cbe5adf62244a5281fc7f50fe87, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Audio_SurfaceMaterial
|
||||
_material:
|
||||
idInternal: 0
|
||||
valueGuidInternal: []
|
||||
groupIdInternal: 0
|
||||
groupGuidInternal: []
|
||||
WwiseObjectReference: {fileID: 11400000, guid: cba7dd3dc6dddc744b665136cf09f95f, type: 2}
|
||||
--- !u!1001 &621599144
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -431,14 +412,14 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 661203441}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 380f7cbe5adf62244a5281fc7f50fe87, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 3ec78f9fa08450a4fb1c6ef69da4e22c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Audio_SurfaceMaterial
|
||||
_material:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Audio_SoundSurface
|
||||
wwiseSwitch:
|
||||
idInternal: 0
|
||||
valueGuidInternal: []
|
||||
valueGuidInternal:
|
||||
groupIdInternal: 0
|
||||
groupGuidInternal: []
|
||||
groupGuidInternal:
|
||||
WwiseObjectReference: {fileID: 11400000, guid: 90b25d313fd10fe4bb34ce68d987f60e, type: 2}
|
||||
--- !u!1 &935580408 stripped
|
||||
GameObject:
|
||||
@@ -461,38 +442,16 @@ MonoBehaviour:
|
||||
idInternal: 0
|
||||
valueGuidInternal:
|
||||
WwiseObjectReference: {fileID: 11400000, guid: 41aa8cbccefacf24b97ee9067316b3dc, type: 2}
|
||||
surfaces:
|
||||
- tag: stone
|
||||
wwiseSwitch:
|
||||
idInternal: 0
|
||||
valueGuidInternal:
|
||||
groupIdInternal: 0
|
||||
groupGuidInternal:
|
||||
WwiseObjectReference: {fileID: 11400000, guid: cea23ef8af49aa54f9c3833465570bb2, type: 2}
|
||||
- tag: wood
|
||||
wwiseSwitch:
|
||||
idInternal: 0
|
||||
valueGuidInternal:
|
||||
groupIdInternal: 0
|
||||
groupGuidInternal:
|
||||
WwiseObjectReference: {fileID: 11400000, guid: 90b25d313fd10fe4bb34ce68d987f60e, type: 2}
|
||||
- tag: carpet
|
||||
wwiseSwitch:
|
||||
idInternal: 0
|
||||
valueGuidInternal:
|
||||
groupIdInternal: 0
|
||||
groupGuidInternal:
|
||||
WwiseObjectReference: {fileID: 11400000, guid: cba7dd3dc6dddc744b665136cf09f95f, type: 2}
|
||||
defaultSwitch:
|
||||
idInternal: 0
|
||||
valueGuidInternal:
|
||||
groupIdInternal: 0
|
||||
groupGuidInternal:
|
||||
WwiseObjectReference: {fileID: 11400000, guid: cea23ef8af49aa54f9c3833465570bb2, type: 2}
|
||||
stepInterval: 0.5
|
||||
minVelocity: 0.4
|
||||
rayDistance: 0.2
|
||||
groundLayer:
|
||||
_stepInterval: 0.5
|
||||
_minVelocity: 0.3
|
||||
_rayDistance: 0.2
|
||||
_groundLayer:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!1 &1391553828
|
||||
@@ -675,15 +634,15 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 1586552165}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 380f7cbe5adf62244a5281fc7f50fe87, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 3ec78f9fa08450a4fb1c6ef69da4e22c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Audio_SurfaceMaterial
|
||||
_material:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Audio_SoundSurface
|
||||
wwiseSwitch:
|
||||
idInternal: 0
|
||||
valueGuidInternal: []
|
||||
valueGuidInternal:
|
||||
groupIdInternal: 0
|
||||
groupGuidInternal: []
|
||||
WwiseObjectReference: {fileID: 11400000, guid: 90b25d313fd10fe4bb34ce68d987f60e, type: 2}
|
||||
groupGuidInternal:
|
||||
WwiseObjectReference: {fileID: 11400000, guid: cba7dd3dc6dddc744b665136cf09f95f, type: 2}
|
||||
--- !u!1 &1758314271
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -807,14 +766,14 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 1758314271}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 380f7cbe5adf62244a5281fc7f50fe87, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 3ec78f9fa08450a4fb1c6ef69da4e22c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Audio_SurfaceMaterial
|
||||
_material:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Audio_SoundSurface
|
||||
wwiseSwitch:
|
||||
idInternal: 0
|
||||
valueGuidInternal: []
|
||||
valueGuidInternal:
|
||||
groupIdInternal: 0
|
||||
groupGuidInternal: []
|
||||
groupGuidInternal:
|
||||
WwiseObjectReference: {fileID: 11400000, guid: cea23ef8af49aa54f9c3833465570bb2, type: 2}
|
||||
--- !u!1001 &1930280930
|
||||
PrefabInstance:
|
||||
@@ -1517,6 +1476,63 @@ MonoBehaviour:
|
||||
eventIdInternal: 0
|
||||
valueGuidInternal:
|
||||
m_callbackDataInternal: {fileID: 0}
|
||||
--- !u!1001 &1671855845641723936
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4395560298612109037, guid: 61f7fe4128138164295ef34aae4f6659, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6521978618824486866, guid: 61f7fe4128138164295ef34aae4f6659, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: AudioManager
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 61f7fe4128138164295ef34aae4f6659, type: 3}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1530,3 +1546,4 @@ SceneRoots:
|
||||
- {fileID: 245714138}
|
||||
- {fileID: 1586552169}
|
||||
- {fileID: 661203445}
|
||||
- {fileID: 1671855845641723936}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class Audio_FootstepsController : MonoBehaviour
|
||||
public AK.Wwise.Event footstepEvent;
|
||||
|
||||
[Header("Surface Configuration")]
|
||||
public List<SurfaceMapping> surfaces = new List<SurfaceMapping>();
|
||||
|
||||
public AK.Wwise.Switch defaultSwitch;
|
||||
|
||||
[Header("Movement Settings")]
|
||||
@@ -27,22 +27,11 @@ public class Audio_FootstepsController : MonoBehaviour
|
||||
|
||||
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()
|
||||
@@ -67,19 +56,18 @@ public class Audio_FootstepsController : MonoBehaviour
|
||||
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))
|
||||
if (hit.collider.TryGetComponent<Audio_SoundSurface>(out var surface))
|
||||
{
|
||||
targetSwitch.SetValue(gameObject);
|
||||
// Debug.Log($"[Footsteps] Switch Wwise set on : {currentTag}");
|
||||
surface.wwiseSwitch.SetValue(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultSwitch.SetValue(gameObject);
|
||||
Debug.LogWarning($"[Footsteps] Tag '{currentTag}' inconnu. Utilisation du switch par défaut.");
|
||||
Debug.LogWarning($"[Footsteps] No GroundSurface component on '{hit.collider.name}'. Utilisation du switch par défaut.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
footstepEvent.Post(gameObject);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
using UnityEngine;
|
||||
using AK.Wwise;
|
||||
|
||||
public class Audio_SoundSurface : MonoBehaviour
|
||||
{
|
||||
public AK.Wwise.Switch wwiseSwitch;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ec78f9fa08450a4fb1c6ef69da4e22c
|
||||
@@ -15,4 +15,4 @@ MonoBehaviour:
|
||||
objectName: inStaircase
|
||||
id: 3708394339
|
||||
guid: 5EE95D9E-014E-4A9E-880A-F1EEF0FE8D8C
|
||||
WwiseStateGroupReference: {fileID: 0}
|
||||
WwiseStateGroupReference: {fileID: 11400000, guid: ea33e74510b6ef84bbdde2121f209e13, type: 2}
|
||||
|
||||
@@ -15,4 +15,4 @@ MonoBehaviour:
|
||||
objectName: inMenu
|
||||
id: 3374585465
|
||||
guid: 8952F29F-BE73-473A-9D08-8294D37259E7
|
||||
WwiseStateGroupReference: {fileID: 0}
|
||||
WwiseStateGroupReference: {fileID: 11400000, guid: ea33e74510b6ef84bbdde2121f209e13, type: 2}
|
||||
|
||||
@@ -15,4 +15,4 @@ MonoBehaviour:
|
||||
objectName: None
|
||||
id: 748895195
|
||||
guid: AA82CE06-EC15-4AB6-A59B-BEDE7C5926C7
|
||||
WwiseStateGroupReference: {fileID: 0}
|
||||
WwiseStateGroupReference: {fileID: 11400000, guid: ea33e74510b6ef84bbdde2121f209e13, type: 2}
|
||||
|
||||
@@ -15,4 +15,4 @@ MonoBehaviour:
|
||||
objectName: inSane
|
||||
id: 3719846035
|
||||
guid: D325E2E9-6F95-4BA9-AF05-2C2E653106FA
|
||||
WwiseStateGroupReference: {fileID: 0}
|
||||
WwiseStateGroupReference: {fileID: 11400000, guid: ea33e74510b6ef84bbdde2121f209e13, type: 2}
|
||||
|
||||
@@ -15,4 +15,4 @@ MonoBehaviour:
|
||||
objectName: inMad
|
||||
id: 1174700730
|
||||
guid: DD04671B-E8B5-4B1A-986A-579728855F92
|
||||
WwiseStateGroupReference: {fileID: 0}
|
||||
WwiseStateGroupReference: {fileID: 11400000, guid: ea33e74510b6ef84bbdde2121f209e13, type: 2}
|
||||
|
||||
Reference in New Issue
Block a user