GameMaker: Studio

GameMaker: Studio

查看统计:
Noise 2016 年 3 月 1 日 上午 9:33
Help with footstep sounds
Hello.
I'm having some issues with audio on Gamemaker: Studio.
Image[i.gyazo.com]
Whenever i start going to any direction, the sound that is supposed to play on image_index 2 it plays for a while but then it suddenly stops playing and i have no idea why is that happening.
< >
正在显示第 1 - 6 条,共 6 条留言
Blind 2016 年 3 月 1 日 上午 11:30 
That is a strange issue - there are a few possibilities

1. You're using sound_isplaying instead of audio_is_playing for your conditional

2. Your sound effect might have a large period of silence at the end of the sound file, keeping too many instances of the sound effect open (if the sound is let to loop and it sounds very rapid - then it's not this)
Noise 2016 年 3 月 1 日 下午 2:10 
引用自 BBX
That is a strange issue - there are a few possibilities

1. You're using sound_isplaying instead of audio_is_playing for your conditional

2. Your sound effect might have a large period of silence at the end of the sound file, keeping too many instances of the sound effect open (if the sound is let to loop and it sounds very rapid - then it's not this)

1. Tried using audio_is_playing and it's still the same thing

2. That's not the case since the lenght of the audio is 0.5 seconds
Blind 2016 年 3 月 1 日 下午 2:12 
Add a visual effect to the same block of code that makes the sound, so you can test if it's the sound or the conditional at fault.
Surface Knight 2016 年 3 月 1 日 下午 8:38 
Something else you might want to try is using alarms. The step event + image_index has caused me problems too; alarms are far more accurate and reliable.

Set up key press and key release events for all of your directions. Create an alarm event. In each key press event, set the new alarm = 1. This starts the code in the alarm instantly.

Then in the alarm, double-check buttons (not keyboard_check_pressed, but keyboard_check) for all of your directions, in an if statement. Inside each of them, add your audio_play_sound function, and restart your alarm equal to an amount that fits your footsteps the way you want them to.

Then at the very end of all that, put in a check to make sure no buttons are being pressed (!keyboard_check) for all of your directions. Inside this check, set your alarm to 0 so you can make sure it doesn't repeat more than you need it to.

Here's a sample from a platform game I'm making that uses the same idea:

Alarm 0:

if(keyboard_check(ord("A"))) {
scr_play_random_footstep();
alarm[0] = 24;
} else if(keyboard_check(ord("D"))) {
scr_play_random_footstep();
alarm[0] = 24;
} else if(!keyboard_check(ord("A")) || !keyboard_check(ord("D"))) {
alarm[0] = 0;
}

That script inside the checks plays a random footstep clip to give it a more authentic sound.

Finally, after all that, go to your key release events for your direction keys (WASD release, or whatever you have them set to) and set the alarm to 0, just to ensure that the alarm doesn't loop after you've released the keys.

Hope this helps!
Thew 2016 年 3 月 1 日 下午 9:20 
This problem might stem from the fact that "image_index" is actually a float, and may have a tiny decimal trailing it. So saying "image_index == 2" might be too specific.

There are a number of ways to fix this, but for testing purposes, you could try something like:
if (image_index >= 2 && image_index <= 2.1 && !audio_is_playing(snd_step)){ audio_play_sound(snd_step, 10, false); }
go60wm 9 月 11 日 上午 2:26 
im getting this issue to, unfortunately this post is 9 years old and i cant find nothing on the issue
< >
正在显示第 1 - 6 条,共 6 条留言
每页显示数: 1530 50