Browse Source

footstep audio added

main
cailean 9 months ago
parent
commit
44f03fd82b
  1. 2
      Assets/3_MarathonEnvs/Scripts/Ragdoll004/SensorObservations.cs
  2. 1
      Assets/3_MarathonEnvs/Scripts/Shared/IOnSensorCollision.cs
  3. 17
      Assets/3_MarathonEnvs/Scripts/Shared/SensorBehavior.cs
  4. 131
      Assets/5_Scenes/DreconDemo.unity
  5. 24
      Assets/8_Scripts/1_Managers/AgentManager.cs
  6. 11
      Assets/8_Scripts/1_Managers/AgentManager.cs.meta
  7. 6
      Assets/8_Scripts/1_Managers/AudioManager.cs
  8. 1
      Assets/8_Scripts/1_Managers/SubtitleManager.cs
  9. 20
      Assets/8_Scripts/2_General/CollisionDetection.cs
  10. 11
      Assets/8_Scripts/2_General/CollisionDetection.cs.meta
  11. 2
      Assets/ML-Agents/Timers/DreconDemo_timers.json
  12. 12
      Assets/Plugins/FMOD/src/RuntimeManager.cs

2
Assets/3_MarathonEnvs/Scripts/Ragdoll004/SensorObservations.cs

@ -36,6 +36,7 @@ public class SensorObservations : MonoBehaviour, IOnSensorCollision
SensorIsInTouch[idx] = 1f; SensorIsInTouch[idx] = 1f;
} }
} }
public void OnSensorCollisionExit(Collider sensorCollider, GameObject other) public void OnSensorCollisionExit(Collider sensorCollider, GameObject other)
{ {
//if (string.Compare(other.gameObject.name, "Terrain", true) !=0) //if (string.Compare(other.gameObject.name, "Terrain", true) !=0)
@ -48,4 +49,5 @@ public class SensorObservations : MonoBehaviour, IOnSensorCollision
SensorIsInTouch[idx] = 0f; SensorIsInTouch[idx] = 0f;
} }
} }
} }

1
Assets/3_MarathonEnvs/Scripts/Shared/IOnSensorCollision.cs

@ -6,6 +6,5 @@ namespace Unity.MLAgents
{ {
void OnSensorCollisionEnter(Collider sensorCollider, GameObject other); void OnSensorCollisionEnter(Collider sensorCollider, GameObject other);
void OnSensorCollisionExit(Collider sensorCollider, GameObject other); void OnSensorCollisionExit(Collider sensorCollider, GameObject other);
} }
} }

17
Assets/3_MarathonEnvs/Scripts/Shared/SensorBehavior.cs

@ -21,8 +21,10 @@ namespace Unity.MLAgents
if (_marathonAgent != null) if (_marathonAgent != null)
_marathonAgent.SensorCollisionEnter(_collider, other); _marathonAgent.SensorCollisionEnter(_collider, other);
if (_onSensorCollision != null) if (_onSensorCollision != null)
{
_onSensorCollision.OnSensorCollisionEnter(_collider, other.gameObject); _onSensorCollision.OnSensorCollisionEnter(_collider, other.gameObject);
} }
}
void OnCollisionExit(Collision other) void OnCollisionExit(Collision other)
{ {
@ -35,7 +37,11 @@ namespace Unity.MLAgents
void OnTriggerEnter(Collider other) void OnTriggerEnter(Collider other)
{ {
if (_onSensorCollision != null) if (_onSensorCollision != null)
{
_onSensorCollision.OnSensorCollisionEnter(_collider, other.gameObject); _onSensorCollision.OnSensorCollisionEnter(_collider, other.gameObject);
}
} }
void OnTriggerExit(Collider other) void OnTriggerExit(Collider other)
{ {
@ -47,5 +53,16 @@ namespace Unity.MLAgents
if (_onSensorCollision != null) if (_onSensorCollision != null)
_onSensorCollision.OnSensorCollisionEnter(_collider, other.gameObject); _onSensorCollision.OnSensorCollisionEnter(_collider, other.gameObject);
} }
void FootCheck(Collision sensor)
{
Debug.Log($"{sensor}");
if (sensor.gameObject.name == "right_foot_heal_senor_l" || sensor.gameObject.name == "left_foot_heal_senor_l")
{
float collision = sensor.relativeVelocity.magnitude;
Debug.Log($"{collision}");
}
}
} }
} }

131
Assets/5_Scenes/DreconDemo.unity

@ -529,11 +529,11 @@ Camera:
y: 0 y: 0
width: 1 width: 1
height: 1 height: 1
near clip plane: 3 near clip plane: 0.01
far clip plane: 5000 far clip plane: 5000
field of view: 10 field of view: 100
orthographic: 0 orthographic: 0
orthographic size: 0.63 orthographic size: 10
m_Depth: -1 m_Depth: -1
m_CullingMask: m_CullingMask:
serializedVersion: 2 serializedVersion: 2
@ -557,8 +557,8 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543} m_GameObject: {fileID: 330585543}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0.31746292, y: -0.6318365, z: 0.6318365, w: 0.31746292} m_LocalRotation: {x: 0.35751197, y: 0.39015585, z: -0.6255848, w: 0.5732428}
m_LocalPosition: {x: 18.84, y: 11.34, z: 2.3} m_LocalPosition: {x: 18.113062, y: 9.285504, z: -0.5535152}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
@ -1079,6 +1079,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 552738672} - component: {fileID: 552738672}
- component: {fileID: 552738673} - component: {fileID: 552738673}
- component: {fileID: 552738674}
m_Layer: 0 m_Layer: 0
m_Name: Mound-Top m_Name: Mound-Top
m_TagString: Untagged m_TagString: Untagged
@ -1095,7 +1096,7 @@ Transform:
m_GameObject: {fileID: 552738671} m_GameObject: {fileID: 552738671}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0.31746292, y: -0.6318365, z: 0.6318365, w: 0.31746292} m_LocalRotation: {x: 0.31746292, y: -0.6318365, z: 0.6318365, w: 0.31746292}
m_LocalPosition: {x: 18.84, y: 11.34, z: 2.3} m_LocalPosition: {x: 18.2, y: 10.3, z: 1.5}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
@ -1118,14 +1119,14 @@ MonoBehaviour:
- m_Script - m_Script
m_LockStageInInspector: m_LockStageInInspector:
m_StreamingVersion: 20170927 m_StreamingVersion: 20170927
m_Priority: 1000 m_Priority: 0
m_StandbyUpdate: 2 m_StandbyUpdate: 2
m_LookAt: {fileID: 0} m_LookAt: {fileID: 0}
m_Follow: {fileID: 0} m_Follow: {fileID: 0}
m_Lens: m_Lens:
FieldOfView: 10 FieldOfView: 10
OrthographicSize: 0.63 OrthographicSize: 0.43
NearClipPlane: 3 NearClipPlane: 1
FarClipPlane: 5000 FarClipPlane: 5000
Dutch: 0 Dutch: 0
ModeOverride: 2 ModeOverride: 2
@ -1148,6 +1149,23 @@ MonoBehaviour:
m_Calls: [] m_Calls: []
m_LegacyBlendHint: 0 m_LegacyBlendHint: 0
m_ComponentOwner: {fileID: 633725997} m_ComponentOwner: {fileID: 633725997}
--- !u!114 &552738674
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 552738671}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 449ef5ebbe24720439ec31d15f7b6f3d, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FocusTracksTarget: 0
m_FocusTracking: 4
m_FocusTarget: {fileID: 0}
m_FocusOffset: 0
m_Profile: {fileID: 11400000, guid: d49226c597192874a9da3c6697ea8d37, type: 2}
--- !u!1 &564611601 --- !u!1 &564611601
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1289,7 +1307,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!114 &756894920 --- !u!114 &756894920
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1355,8 +1373,53 @@ Transform:
- {fileID: 756894921} - {fileID: 756894921}
- {fileID: 273313794} - {fileID: 273313794}
- {fileID: 1403332545} - {fileID: 1403332545}
- {fileID: 842964162}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &842964161
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 842964162}
- component: {fileID: 842964163}
m_Layer: 0
m_Name: Agent Manager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &842964162
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 842964161}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 760971828}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &842964163
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 842964161}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8c398b676a196214e9a3612ad50bcd56, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &882491594 --- !u!1 &882491594
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1425,7 +1488,7 @@ MonoBehaviour:
- m_Script - m_Script
m_LockStageInInspector: m_LockStageInInspector:
m_StreamingVersion: 20170927 m_StreamingVersion: 20170927
m_Priority: 200 m_Priority: 200000
m_StandbyUpdate: 2 m_StandbyUpdate: 2
m_LookAt: {fileID: 2036798640} m_LookAt: {fileID: 2036798640}
m_Follow: {fileID: 6929616558284982652} m_Follow: {fileID: 6929616558284982652}
@ -2650,7 +2713,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1955078056} m_GameObject: {fileID: 1955078056}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: -0.000000563939, y: 0.7132504, z: -0.7009093, w: -0.0000005738685} m_LocalRotation: {x: 0.0000005639385, y: 0.7132504, z: -0.7009093, w: 0.0000005738679}
m_LocalPosition: {x: 18.113062, y: 10.981609, z: -0.6314695} m_LocalPosition: {x: 18.113062, y: 10.981609, z: -0.6314695}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
@ -7976,6 +8039,7 @@ GameObject:
- component: {fileID: 5040618326987493057} - component: {fileID: 5040618326987493057}
- component: {fileID: 2789610092711255094} - component: {fileID: 2789610092711255094}
- component: {fileID: 8139415419497741796} - component: {fileID: 8139415419497741796}
- component: {fileID: 8139415419497741797}
m_Layer: 6 m_Layer: 6
m_Name: RightFoot m_Name: RightFoot
m_TagString: Untagged m_TagString: Untagged
@ -11391,7 +11455,7 @@ SphereCollider:
m_Bits: 0 m_Bits: 0
m_LayerOverridePriority: 0 m_LayerOverridePriority: 0
m_IsTrigger: 1 m_IsTrigger: 1
m_ProvidesContacts: 0 m_ProvidesContacts: 1
m_Enabled: 1 m_Enabled: 1
serializedVersion: 3 serializedVersion: 3
m_Radius: 0.03 m_Radius: 0.03
@ -11794,7 +11858,7 @@ SphereCollider:
m_Bits: 0 m_Bits: 0
m_LayerOverridePriority: 0 m_LayerOverridePriority: 0
m_IsTrigger: 1 m_IsTrigger: 1
m_ProvidesContacts: 0 m_ProvidesContacts: 1
m_Enabled: 1 m_Enabled: 1
serializedVersion: 3 serializedVersion: 3
m_Radius: 0.03 m_Radius: 0.03
@ -12324,6 +12388,25 @@ ArticulationBody:
m_Immovable: 0 m_Immovable: 0
m_UseGravity: 1 m_UseGravity: 1
m_CollisionDetectionMode: 0 m_CollisionDetectionMode: 0
--- !u!114 &8139415419497741797
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4147160452002222200}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2c5b489d1464aad4a923b9eb7846f423, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FootstepAudio:
Guid:
Data1: -1958731946
Data2: 1116987885
Data3: -2135420744
Data4: -630416087
Path: event:/Footstep
--- !u!4 &8159240303487704382 --- !u!4 &8159240303487704382
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -12789,6 +12872,7 @@ GameObject:
- component: {fileID: 4803592416560392984} - component: {fileID: 4803592416560392984}
- component: {fileID: 42398579111443287} - component: {fileID: 42398579111443287}
- component: {fileID: 3634075524347290163} - component: {fileID: 3634075524347290163}
- component: {fileID: 8548312743625172600}
m_Layer: 6 m_Layer: 6
m_Name: LeftFoot m_Name: LeftFoot
m_TagString: Untagged m_TagString: Untagged
@ -12796,6 +12880,25 @@ GameObject:
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!114 &8548312743625172600
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8548312743625172599}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2c5b489d1464aad4a923b9eb7846f423, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FootstepAudio:
Guid:
Data1: -1958731946
Data2: 1116987885
Data3: -2135420744
Data4: -630416087
Path: event:/Footstep
--- !u!171741748 &8550852056549031879 --- !u!171741748 &8550852056549031879
ArticulationBody: ArticulationBody:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

24
Assets/8_Scripts/1_Managers/AgentManager.cs

@ -0,0 +1,24 @@
using FMODUnity;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AgentManager : MonoBehaviour
{
[SerializeField]
private void OnEnable()
{
CollisionDetection.m_PlaySoundOnContact += PlayOneShot;
}
private void OnDisable()
{
CollisionDetection.m_PlaySoundOnContact -= PlayOneShot;
}
private void PlayOneShot(GameObject obj, float force, EventReference sound)
{
AudioManager.instance.PlayOneShotAttached(sound, obj, force);
}
}

11
Assets/8_Scripts/1_Managers/AgentManager.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8c398b676a196214e9a3612ad50bcd56
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

6
Assets/8_Scripts/1_Managers/AudioManager.cs

@ -37,6 +37,12 @@ public class AudioManager : MonoBehaviour
return soundInst; return soundInst;
} }
// Physic's based sounds
public void PlayOneShotAttached(EventReference sound, GameObject obj, float force)
{
RuntimeManager.PlayOneShotAttached(sound, obj, force, 0.1f);
}
public void StopSound(EventInstance soundInst) public void StopSound(EventInstance soundInst)
{ {
soundInst.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); soundInst.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);

1
Assets/8_Scripts/1_Managers/SubtitleManager.cs

@ -11,7 +11,6 @@ public class SubtitleManager : MonoBehaviour
[Header("Text")] [Header("Text")]
public TMP_Text m_Text; public TMP_Text m_Text;
[Header("Audio")] [Header("Audio")]
[Header("Audio")]
[SerializeField] [SerializeField]
private EventReference m_NarrationSFX; private EventReference m_NarrationSFX;
[SerializeField] [SerializeField]

20
Assets/8_Scripts/2_General/CollisionDetection.cs

@ -0,0 +1,20 @@
using FMODUnity;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CollisionDetection : MonoBehaviour
{
[SerializeField]
private EventReference m_FootstepAudio;
// Start is called before the first frame update
public delegate void onContactSoundDelegate(GameObject obj, float force, EventReference soundObject);
public static onContactSoundDelegate m_PlaySoundOnContact;
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "200x200")
{
m_PlaySoundOnContact?.Invoke(this.gameObject, collision.relativeVelocity.magnitude, m_FootstepAudio);
}
}
}

11
Assets/8_Scripts/2_General/CollisionDetection.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2c5b489d1464aad4a923b9eb7846f423
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

2
Assets/ML-Agents/Timers/DreconDemo_timers.json

@ -1 +1 @@
{"count":1,"self":67.9475136,"total":69.8104441,"children":{"InitializeActuators":{"count":1,"self":0.0010044,"total":0.0010044,"children":null},"InitializeSensors":{"count":1,"self":0,"total":0,"children":null},"AgentSendState":{"count":3834,"self":0.0196829,"total":0.4940573,"children":{"CollectObservations":{"count":1917,"self":0.4553368,"total":0.4553368,"children":null},"WriteActionMask":{"count":1917,"self":0.0015046999999999999,"total":0.0015046999999999999,"children":null},"RequestDecision":{"count":1917,"self":0.0175329,"total":0.0175329,"children":null}}},"DecideAction":{"count":3834,"self":0.79366019999999993,"total":0.79366019999999993,"children":null},"AgentAct":{"count":3834,"self":0.5737057,"total":0.5737057,"children":null}},"gauges":{"DReCon-v0.CumulativeReward":{"count":2,"max":314.91394,"min":55.0234528,"runningAverage":184.968689,"value":314.91394,"weightedAverage":119.996078}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1712665495","unity_version":"2022.3.5f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.5f1\\Editor\\Unity.exe -projectpath C:\\Users\\caile\\Desktop\\Projects\\24_3-Moloch\\2_Unity\\Expeirments\\Drecon2022 -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-caile -hubSessionId 8620dcf5-e9e3-4cd2-bcfa-e78675b590b7 -accessToken ciFqIxVRTpefMqfWDVXsyVxdEZBGzbXJXI-wHrHw5kI005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"DreconDemo","end_time_seconds":"1712665565"}} {"count":1,"self":232.505216,"total":239.2866111,"children":{"InitializeActuators":{"count":1,"self":0.0010048,"total":0.0010048,"children":null},"InitializeSensors":{"count":1,"self":0.0007312,"total":0.0007312,"children":null},"AgentSendState":{"count":13915,"self":0.0733683,"total":1.7356899,"children":{"CollectObservations":{"count":6958,"self":1.6299496999999998,"total":1.6299496999999998,"children":null},"WriteActionMask":{"count":6958,"self":0.0088043,"total":0.0088043,"children":null},"RequestDecision":{"count":6958,"self":0.023567599999999998,"total":0.023567599999999998,"children":null}}},"DecideAction":{"count":13915,"self":2.9996845999999997,"total":2.9996845999999997,"children":null},"AgentAct":{"count":13915,"self":2.0442956,"total":2.0442955,"children":null}},"gauges":{"DReCon-v0.CumulativeReward":{"count":10,"max":1277.80322,"min":63.5799446,"runningAverage":551.9441,"value":80.70452,"weightedAverage":599.973}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1712677254","unity_version":"2022.3.5f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.5f1\\Editor\\Unity.exe -projectpath C:\\Users\\caile\\Desktop\\Projects\\24_3-Moloch\\2_Unity\\Expeirments\\Drecon2022 -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-caile -hubSessionId 8620dcf5-e9e3-4cd2-bcfa-e78675b590b7 -accessToken ciFqIxVRTpefMqfWDVXsyVxdEZBGzbXJXI-wHrHw5kI005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"DreconDemo","end_time_seconds":"1712677493"}}

12
Assets/Plugins/FMOD/src/RuntimeManager.cs

@ -1235,11 +1235,11 @@ retry:
instance.release(); instance.release();
} }
public static void PlayOneShotAttached(EventReference eventReference, GameObject gameObject) public static void PlayOneShotAttached(EventReference eventReference, GameObject gameObject, float pitch, float volume)
{ {
try try
{ {
PlayOneShotAttached(eventReference.Guid, gameObject); PlayOneShotAttached(eventReference.Guid, gameObject, pitch, volume);
} }
catch (EventNotFoundException) catch (EventNotFoundException)
{ {
@ -1247,11 +1247,11 @@ retry:
} }
} }
public static void PlayOneShotAttached(string path, GameObject gameObject) public static void PlayOneShotAttached(string path, GameObject gameObject, float pitch, float volume)
{ {
try try
{ {
PlayOneShotAttached(PathToGUID(path), gameObject); PlayOneShotAttached(PathToGUID(path), gameObject, pitch, volume);
} }
catch (EventNotFoundException) catch (EventNotFoundException)
{ {
@ -1259,7 +1259,7 @@ retry:
} }
} }
public static void PlayOneShotAttached(FMOD.GUID guid, GameObject gameObject) public static void PlayOneShotAttached(FMOD.GUID guid, GameObject gameObject, float pitch, float volume)
{ {
var instance = CreateInstance(guid); var instance = CreateInstance(guid);
#if UNITY_PHYSICS_EXIST #if UNITY_PHYSICS_EXIST
@ -1269,6 +1269,8 @@ retry:
#else #else
AttachInstanceToGameObject(instance, gameObject.transform); AttachInstanceToGameObject(instance, gameObject.transform);
#endif #endif
instance.setVolume(volume);
instance.setPitch(pitch);
instance.start(); instance.start();
instance.release(); instance.release();
} }

Loading…
Cancel
Save