• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Sound alternation

Q

Qing Donnie Yoshi

Guest
Does anyone know how to Alternate sounds/audios, like say for instance footsteps with 2 different audios (left foot audio play and then right foot audio play and etc.) Is there a specific variable I can use for that, just like how choose is a built in variable?
 

obscene

Member
You can make your own script for this. The idea would be to increment a variable every time you call the script, then use the modulo function to choose the correct one.

var snd=scr_alternate(snd_footstep_left,snd_foostep_right);
audio_play_sound(snd,1,0);

Script....
footstep_count+=1;
return argument[footstep_count mod argument_count-1];

I think that should work.
 
Q

Qing Donnie Yoshi

Guest
You can make your own script for this. The idea would be to increment a variable every time you call the script, then use the modulo function to choose the correct one.

var snd=scr_alternate(snd_footstep_left,snd_foostep_right);
audio_play_sound(snd,1,0);

Script....
footstep_count+=1;
return argument[footstep_count mod argument_count-1];

I think that should work.
will this code work with anything else, because I'm asking for Pac-Man related stuff? the footstep thing was just an example.
 

Yal

šŸ§ *penguin noises*
GMC Elder
Randomly alter its playback speed a bit, it will sound like it's pitched up and down a bit (so it's more natural variations, instead of always sounding the same):
Code:
///sfx_pitchy(sound)
var n = audio_play_sound(argument0,10,false);
audio_sound_pitch(n,1 + random_range(-0.1,0.1))
return n;
 
Top