mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-14 08:17:13 +00:00
play explosion sound
This commit is contained in:
parent
99c1cf8ecc
commit
ec43361325
2 changed files with 113 additions and 0 deletions
|
@ -23295,6 +23295,7 @@ GameObject:
|
|||
- component: {fileID: 11400000}
|
||||
- component: {fileID: 10800000}
|
||||
- component: {fileID: 7300375720519918962}
|
||||
- component: {fileID: 3101637387823967307}
|
||||
m_Layer: 0
|
||||
m_Name: Explosion
|
||||
m_TagString: Untagged
|
||||
|
@ -23402,6 +23403,102 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 09d6d62b56f152e449d502dce1494c75, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!82 &3101637387823967307
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 100010}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 128
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 200
|
||||
Pan2D: 0
|
||||
rolloffMode: 1
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
rolloffCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
panLevelCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
spreadCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
reverbZoneMixCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!1 &100012
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using SanAndreasUnity.Behaviours.Audio;
|
||||
using SanAndreasUnity.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -25,6 +26,8 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
GameObject m_smokeGameObject;
|
||||
GameObject m_flameGameObject;
|
||||
|
||||
public static AudioClip ExplosionSound { get; private set; }
|
||||
|
||||
|
||||
|
||||
void Awake_Damage()
|
||||
|
@ -200,6 +203,9 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
physicsForce.explosionForce *= forceFactor;
|
||||
physicsForce.upwardsModifier *= forceFactor;
|
||||
|
||||
// assign explosion sound
|
||||
F.RunExceptionSafe(() => AssignExplosionSound(explosionGo));
|
||||
|
||||
}
|
||||
|
||||
void DetachFrameDuringExplosion(
|
||||
|
@ -227,6 +233,16 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
Object.Destroy(meshFilter.gameObject, VehicleManager.Instance.explosionLeftoverPartsLifetime * Random.Range(0.8f, 1.2f));
|
||||
}
|
||||
|
||||
void AssignExplosionSound(GameObject explosionGo)
|
||||
{
|
||||
if (null == ExplosionSound)
|
||||
ExplosionSound = AudioManager.CreateAudioClipFromSfx("GENRL", 45, 1);
|
||||
|
||||
var audioSource = explosionGo.GetComponentOrThrow<AudioSource>();
|
||||
audioSource.clip = ExplosionSound;
|
||||
audioSource.Play();
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected()
|
||||
{
|
||||
// draw sphere indicating explosion damage radius
|
||||
|
|
Loading…
Reference in a new issue