paranoid_giraffe 14 Posted June 15, 2016 Hello, I am working on a mission where you have to track packages that fell from a helicopter before it crashed, and I have a transponder sound play on loop. The sound works fine, and it loops, and the volume is good when you are near it, but you can also hear it very well from about 500 meters away. I'll drop code in and explain what I wish to do: I want the sound to be very audible when you are near it, and drop off to be inaudible around 40-50 meters. Is this possible? In the cargo object I have the following in the init: _null = [this] execVM "gps_sound.sqf"; This is in the Description.ext file in the mission folder to define the sound class: class CfgSounds { sounds[] = {}; class blip { name = ""; // start path to sound file in AddOn with @ sound[] = {"\transponder.ogg", db+1, 1}; titles[] = {}; }; }; And this is the script in which the sound is actually played, which is called by the init from the cargo box: _obj = _this select 0; sleep 1; while {true} do { _obj say3D ["blip",100,1.0]; sleep 2; }; Share this post Link to post Share on other sites
serena 150 Posted June 15, 2016 Is generating sound device in player inventory or at crash site? If is in player inventory, you better use playSound3D command that allow you to adjust volume manually. Also this command allow you to specify sound file directly, without declaring something in description.ext Share this post Link to post Share on other sites
paranoid_giraffe 14 Posted June 15, 2016 The device generating the sound is a cargo box in a forest. The player is given the general location and has to find it from there. The object in which the code for the init is placed is the cargo box. Everything works except for the fact that the player can hear the ping from +500 meters if the environment is calmed down and quiet. I can adjust the volume of the sound in the description.ext, its just that I want the sound to be very loud when close, and not audible at all when more than 50 meters away Share this post Link to post Share on other sites
Fiddi 68 Posted June 15, 2016 Something like this perhaps: playSound3D ["\transpoder.ogg", _obj, false, getPos _obj, 1, 1, 0]; The last three numbers are volume, pitch and distance. Volume is self-explanatory. Pitch is also self-explanatory. Distance is how far away you can hear the sound regardless of volume. 0 is no max distance, and is dependent on volume instead. Share this post Link to post Share on other sites
serena 150 Posted June 15, 2016 Try: playSound3D [_path_to_sound_file, nil, false, _position, _volume, _pitch]; Share this post Link to post Share on other sites
paranoid_giraffe 14 Posted June 15, 2016 Something like this perhaps: playSound3D ["\transpoder.ogg", _obj, false, getPos _obj, 1, 1, 0]; The last three numbers are volume, pitch and distance. Volume is self-explanatory. Pitch is also self-explanatory. Distance is how far away you can hear the sound regardless of volume. 0 is no max distance, and is dependent on volume instead. I used this method before to try it but it didn't work when I changed the distance. Here is my updated code: (EDIT: for some reason, my comment below the code block didnt show up.) Anyways, when I change the final number (0) in the array to anything but zero (0), the sound is either not playing or completely inaudible. I have used this before, and I know it works with 0. Also, MISSION_ROOT is correctly defined in init.sqf via Killzone_Kid's tutorial for doing so. _obj = _this select 0; sleep 1; while {true} do { playSound3D [ (MISSION_ROOT +'transponder.ogg'),_obj, false, getPos _obj, 1, 1, 0]; sleep 2; }; Share this post Link to post Share on other sites
serena 150 Posted June 15, 2016 Who not just: playSound3D [ "transponder.ogg", nil, false, getPos _obj, _volume]; Where volume may be static value 1... or dynamic value based on distance between box and player Share this post Link to post Share on other sites
paranoid_giraffe 14 Posted June 15, 2016 Who not just: playSound3D [ "transponder.ogg", nil, false, getPos _obj, _volume]; Where volume may be static value 1... or dynamic value based on distance between box and player AH! I figured out what the problem was. playSound3D uses the position you specific with getPos and overrides the object parameter entered. You can use either an object (and it will use correct position), or you can specify a position. When specifying position, you have to use getPosASL, otherwise it won't work. Thanks to both of you! 1 Share this post Link to post Share on other sites