play projectile sound

This commit is contained in:
in0finite 2020-12-21 03:01:20 +01:00
parent f61a4c829f
commit 4acfe0e401
2 changed files with 28 additions and 14 deletions

View file

@ -127,7 +127,7 @@ AudioSource:
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_PlayOnAwake: 0
m_Volume: 1
m_Pitch: 1
Loop: 0
@ -137,9 +137,9 @@ AudioSource:
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
MaxDistance: 300
Pan2D: 0
rolloffMode: 0
rolloffMode: 2
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
@ -148,22 +148,22 @@ AudioSource:
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
value: 0.9977585
inSlope: -2.0526855
outSlope: -2.0526855
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
inWeight: 0
outWeight: 0.066985644
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
inSlope: -0.09824785
outSlope: -0.09824785
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
inWeight: 0.107655525
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
@ -172,7 +172,7 @@ AudioSource:
m_Curve:
- serializedVersion: 3
time: 0
value: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0

View file

@ -169,6 +169,7 @@ namespace SanAndreasUnity.Behaviours
};
private Geometry.GeometryParts m_projectileModel;
private static AudioClip s_projectileSound;
@ -296,6 +297,18 @@ namespace SanAndreasUnity.Behaviours
m_projectileModel = Geometry.Load (def.ModelName, def.TextureDictionaryName);
}
void LoadProjectileAudio()
{
if (null == s_projectileSound)
{
s_projectileSound = Audio.AudioManager.CreateAudioClipFromSfx("GENRL", 136, 68);
// float[] samples = new float[s_projectileSound.samples];
// s_projectileSound.GetData(samples, 0);
// s_projectileSound = AudioClip.Create(s_projectileSound.name, s_projectileSound.samples * 2, s_projectileSound.channels, s_projectileSound.frequency, false);
// s_projectileSound.SetData(samples.Concat(samples.Reverse()).ToArray(), 0);
}
}
internal static void OnWeaponCreatedByServer(NetworkedWeapon networkedWeapon)
{
@ -384,6 +397,7 @@ namespace SanAndreasUnity.Behaviours
this.ProjectilePrefab = WeaponsSettings.projectilePrefab;
this.ReloadTime = WeaponsSettings.projectileReloadTime;
F.RunExceptionSafe(this.LoadProjectileModel);
F.RunExceptionSafe(this.LoadProjectileAudio);
}
}
@ -651,7 +665,7 @@ namespace SanAndreasUnity.Behaviours
if (this.FiresProjectile)
{
Projectile.Create(this.ProjectilePrefab, firePos, Quaternion.LookRotation(fireDir), null, m_projectileModel, m_ped);
Projectile.Create(this.ProjectilePrefab, firePos, Quaternion.LookRotation(fireDir), s_projectileSound, m_projectileModel, m_ped);
return;
}