Play last bullet sound differently

JIMBOB Posts: 23Member
Good for Garand weapon :D

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent (typeof(vp_FPWeaponShooter))]

public class Jims_GarandLstSfx : MonoBehaviour
{
public AnimationClip FireAnim1 = null;
public AnimationClip FireAnim2 = null;

public AudioClip FireSFX1 = null;
public AudioClip FireSFX2 = null;

vp_FPWeaponShooter m_FPWeaponShooter = null;

protected vp_PlayerEventHandler m_Player = null;

void Awake ()
{
m_FPWeaponShooter = GetComponent<vp_FPWeaponShooter> ();
m_Player = transform.root.GetComponent<vp_PlayerEventHandler> ();
}

protected virtual void OnEnable()
{
if (m_Player != null)
m_Player.Register(this);
}

protected virtual void OnDisable()
{
if (m_Player != null)
m_Player.Unregister(this);
}


void Update()
{
if (m_Player.CurrentWeaponAmmoCount.Get() < 2 ) {
m_FPWeaponShooter.AnimationFire = FireAnim2;
m_FPWeaponShooter.SoundFire = FireSFX2;
} else {
m_FPWeaponShooter.AnimationFire = FireAnim1;
m_FPWeaponShooter.SoundFire = FireSFX1;
}

}

}
Sign In or Register to comment.