Let's say you're making a top-down shooter and you want the player to really get into the role of the characters they're controlling. You would want them to experience the environment in the same way and this includes the sounds he/she will hear. Since we already have our emitter and listener, let's take a look at how we can affect the audio based on the orientation of the player (the listener).
You can use the code and setup from the previous recipe; we're just going to adjust some of the code here and there.
Open
obj_player
and delete the Create event.In the Step event, add the following code to the bottom of your code block:
image_angle = point_direction(x, y, mouse_x, mouse_y); audio_listener_orientation(lengthdir_x(1, image_angle), lengthdir_y(1, image_angle), 5, 0, 0, -1);
Once this is done you can test the new code. Move the player around the room but move the mouse as well. The player will rotate around based on the mouse's...