Changes the position of the given listener within the audio space.


audio_listener_set_position(index, x, y, z);

Argument Description
index The listener to get the data for (default 0).
x The x position of the listener (default 0).
y The y position of the listener (default 0).
z The z position of the listener (default 0).

Returns: N/A


With this function you can change the position of a given listener within the 3D audio space. The default listener index is 0, but you can use the function audio_get_listener_info to get the different indices available for the target platform. The example image below shows the default position for the listener in the audio space: As you can see, the default position is (0, 0, 0) but you would normally use this function to move the listener around with the player object within your game and so change the way audio created by emitters is heard by the player, for example, in the image below of a top down game, the player instance sets the listener which will cause the audio from the various emitters to "change" as the player moves around the level:


var num = audio_get_listener_count();
for(var i = 0; i < num; ++i;)
   var info = audio_get_listener_info(i);
   var data = audio_listener_get_data(info[? "index"]);
   if data[? "x"] != 0
      audio_listener_set_position(info[? "index"], 0, 0, 0);

The above code checks the number of listeners available then loops through them and if their x position is not 0, it sets their position to 0, 0, 0.

Back: Audio Listeners
Next: audio_listener_set_velocity
© Copyright YoYo Games Ltd. 2018 All Rights Reserved