Shoot sound

This commit is contained in:
JonatanRek 2020-02-01 20:21:41 +01:00
parent d256f7dd45
commit 8d1c4a02c2
2 changed files with 106 additions and 0 deletions

View File

@ -10,6 +10,7 @@ GameObject:
m_Component:
- component: {fileID: 2179056336067526864}
- component: {fileID: 5029589411118839234}
- component: {fileID: -1682145434106595162}
m_Layer: 0
m_Name: Weapon_1
m_TagString: Untagged
@ -52,6 +53,107 @@ MonoBehaviour:
type: 3}
damage: 5
fireRate: 0.5
animator: {fileID: 0}
player: {fileID: 0}
hit: 0
audioSource: {fileID: -1682145434106595162}
shootSound: {fileID: 8300000, guid: f8179c48d63ecda4aad05d68f0c60de8, type: 3}
--- !u!82 &-1682145434106595162
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2179056336067526865}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
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: 0
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 &4234349944776735638
GameObject:
m_ObjectHideFlags: 0

View File

@ -16,6 +16,9 @@ public class WeaponManager : MonoBehaviour
public PlayerManager player;
public bool hit = false;
public AudioSource audioSource = new AudioSource();
public AudioClip shootSound;
// Start is called before the first frame update
void Start()
{
@ -36,6 +39,7 @@ public class WeaponManager : MonoBehaviour
if (particleShoot != null && player.ammo > 1)
{
GameObject shoot = Instantiate(particleShoot, spawnShoot.transform.position, spawnShoot.transform.rotation);
audioSource.PlayOneShot(shootSound);
player.ammo -= 2;
Destroy(shoot, 0.3f);
fireTime = fireRate + Time.time;