- Home /
audio rate changeing depending on axes
i am using yield WaitForSeconds(reloadTime); in the middle of my Fire() function but the speed of fire varies depending on which direction i'm traveling for example it may be twice as fast along the x as it is on the z. it is happening both in my gun and footsteps... with the footsteps it is probably due to frame rate but im lost on whats causing it on the gun...plz help.
it's a long script so i just included the important bits.
Gun:
function Awake() {
load();
}
function Update() {
if(Input.GetButton("Fire1")) {
if(loaded){
Fire();
}
}
}
function Fire(){
loaded = false;
muzzleFlash.enabled = true;
audio.PlayOneShot(shotSound);
var instance : Rigidbody = Instantiate(bullet, SpawnPoint.position,
SpawnPoint.rotation);
instance.velocity = SpawnPoint.forward * speed;
Ammo +=-1;
yield WaitForSeconds(reloadTime);
if(Ammo > 0){
loaded = true;
}
else{
loaded = false;
}
}
function load(){
audio.PlayOneShot(equip2);
yield WaitForSeconds(2);
loaded = true;
}
footsteps:----------------------------------------------------------------------------
function Update (){
// counter random++; if(random >= 10){
random = 0;
} if(random > 8) { timer = true;
} else { timer = false; }
}
function Run (){
if(Input.GetKey("w")){
if (timer) {
audio.PlayOneShot(runSound);
audio.volume = noiseLVL;
}
}
Have you looked at velocity update mode? http://unity3d.com/support/documentation/ScriptReference/AudioListener-velocityUpdate$$anonymous$$ode.html
Please format your code properly when you post, it's not hard.