Im calling Audiosource.PlayOneShot from a coroutine like this:
while(isAttacking) {
AudioSource.PlayOneShot(clip);
//projectile code here
yield return new WaitForSeconds(fireRate);
}
But this only plays the sound at a frame by frame basis as i understand it so it ends up sounding weird because its not being played at a constant beat.
So how can i play the sound at a consistant rate.
Maybe some way to play sounds from a separate thread that can update much faster?
Preferably i want code to work on as many platforms as possible.
Edit: I am aware that i can make up for slow frame rate by using something like CustomFixedUpdate, but that still results in my shoot code being called only on frame updates, that’s fine for the visuals and the physics, but for the sound effects the shooting sounds weird if the timing is off.