Hi m finding some problem when i play audio during firing,
var cross:boolean = true;
var counter :float;
var firesound : AudioClip;
function Start()
{
animation[“fire”].wrapMode = WrapMode.Once;
animation[“Crouch idle”].wrapMode = WrapMode.Once;
}
function Update ()
{
if(cross)
{
StandFire();
}
else
{
crouch();
}
}
function StandFire()
{
transform.animation.CrossFade("fire");// plays stand fire animation
AudioSource.PlayClipAtPoint(firesound, transform.position);
counter += Time.deltaTime;
if(counter > 4)// after 4 seconds animation changes to "crouch-idle"
{
cross = false;
counter =0.0;
}
}
function crouch()
{
transform.animation.CrossFade("Crouch idle");// plays crouch idle animation
counter += Time.deltaTime;
if(counter > 4)// after 4 seconds animation changes to "fire"
{
cross = true;
counter =0.0;
}
}
My problem is when “fire” animation is playing, fire sound should come and play only once, but it is playing many times. Plz help me, if there is any other way to achieve this, fire sound must play only when “fire” animation is playing and sound should play only once…