• 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!

Legacy GM Audio emitter sound problem

H

Holy Moly

Guest
I have set 3d sounds to some bullets in my game, so the sound has falloff and changes it's speaker orientation depending on the listener (player) position. Those bullets make a sound as they travel. At this point, the 3d sound works perfectly.

However, when a bullet is destroyed, I want it to a make a different sound with the same falloff and sound orientation properties. The problem is that if I don't free each bullet's emitter on destroy event, it will result on a memory leack; and freeing a bullet's emitter seems to not be allowing me to play the "bullet destroy sound effect". I had thought on freeing the bullet's emitters on room end, but if the bullet spawner makes too many bullets before room end, it will also result on a memory leack.

Is there a way to don't stop an object's last emitted sound after that emitter was freed?
 

obscene

Member
Nope. Personally I have a custom script for these situations which just calls audio_play_sound_at and uses my global falloff settings so it will match up to the sounds of your emitters.

Code:
///scr_audio_play_sound_at(asset,gain,x,y)
gml_pragma(forceinline);
var s=audio_play_sound_at(argument0,argument2,argument3,1,global.falloff_ref_dist,global.falloff_max_dist,global.falloff_factor,false,1);
audio_sound_gain(s,argument1*global.sfx_volume_setting*global.sfx_internal_gain,0);
return s;
 

Smiechu

Member
In destruction event you can "send" the ID of sound emmiter to your "obj_game" or whatever you have for governing the general things in your game...
Game event would store the Id's in a ds_queue... Than you need to make some conditions for cleaning the queue...
For example if queue count is 100 - destroy 20 ID from the front of the queue...
 
Top