Legacy GM Playing sound at a 2D location (SOLVED)

Fixer90

Member
So I'm making a 2D platformer, and I want to play a sound (snd_slash) at a specific location (x and y). What is the best way to go about this? I'm somewhat skeptical about using audio_play_sound_at without any knowledge of it due to its arguments.
 

TheBroman90

Member
To use audio_play_sound_at you have to set up some stuff first, but after that it's really easy to use.

In the Create Event of your control object, create some variables.

Code:
// How the sound fades out over time. Play with the numbers and see what works for your game.
global.falloff_ref = 100;
global.falloff_max = 300;
audio_falloff_set_model(audio_falloff_linear_distance);
And in the Step Event we update were our "ears" are. Usually in the middle of the view.

Code:
audio_listener_position(view_xview[0] + (view_wview[0] / 2), view_yview[0] + (view_hview[0] / 2), 0);
audio_listener_orientation(0, 0, 1000, 0, -1, 0);
When that's done, instances can play sounds at their position in the room.

Code:
audio_play_sound_at(snd_sound, x, y, 0, global.falloff_ref, global.falloff_max, 1, false, 1);
 

rogonow

Member
I can't find a method with GM to set the volume to 0 at one side and to max at the other side. I hear it always with my 2 ears. I hear it louder at one side and more scilent at other side with that code. Can someone help me plz? I need such a horizontal volume gradient. GM7.0 (or GM 6.1) had such function because I have used it.
UPDATE: I tried a work around with mono chanel, but that doesn't work. GM makes the volume equal to each side :( .
 
Last edited:
Top