audio_listener_set_orientation


描述

With this function you can change the orientation of the 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 look at vector and up vector are based on the values that are resolved from the given relative x, y and z positions, and default to (0, 0, -1) for the look at vector and (0, 1, 0) for the up vector, as shown in the illustration below:

Changing the given listener orientation with this function will change how sound created by audio emitters around the game room are perceived by the player of your game. In the example below, sounds created by the emitter when the listener is at the default position would appear to be coming from below and to the right of the listener, but with the new position and orientation of the listener they will now be perceived as coming from above and to the right.


语法:

audio_listener_set_orientation(index, lookat_x, lookat_y, lookat_z, up_x, up_y, up_z);


参数 描述
index The listener to set the orientation of.
lookat_x The x look vector (default 0).
lookat_y The y look vector (default 0).
lookat_z The z look vector (default -1).
up_x The x up vector (default 0).
up_y The y up vector (default 1).
up_z The z up vector (default 0).


返回:

N/A(无返回值)


例如:

var _vmat = camera_get_view_mat(view_camera[0]);
audio_listener_set_position(global.Player_Listener, _vmat[0], _vmat[1], _vmat[2]);
audio_listener_set_orientation(info[? "index"], _vmat[3], _vmat[4], _vmat[5], _vmat[6], _vmat[7], _vmat[8]);

The above code retrieves the view matrix for camera view [0] and then uses it to set the audio listener position and orientation for the listener with the ID stored in the global variable "Player_Listener".