O'Reilly logo

GameMaker Cookbook by Brandon Gardiner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adjusting the listener orientation

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).

Getting ready

You can use the code and setup from the previous recipe; we're just going to adjust some of the code here and there.

How to do it

  1. Open obj_player and delete the Create event.
  2. 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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required