Skip to main content
GameDev.net gamedev.net
🔒 Locked

Directional sound depending on camera movement in openAL

Started by ChimDev Apr 14, 2020 at 9:20 PM 1 replies 6.1k views
Original Post
ChimDev
ChimDev

I'm trying to get directional sound to work correctly in openAL. I'm getting sound, and it IS directional, but I'll explain the problem. The game is a 3d first person game, and if I move the character around an audio source the audio behaves as expected and seems to rotate appropriately, BUT the rotation of the player camera has no effect. Below is my current code, which is just a test, changing the -1 to 1 for example has zero effect in how the audio is perceived. The method is called every frame in the game, so it's not that. Anyone have a clue about what the issue could be?

To reiterate, setting AL_ORIENTATION has zero effect for me, whatever I set the values to.

		float[] playerOrientation = new float[6]; 
		
		// direction-vector
		playerOrientation[0] = 0; // x
		playerOrientation[1] = 0; // y
		playerOrientation[2] = -1; // z

		// up-vector
		playerOrientation[3] = 0; // x
		playerOrientation[4] = 1; // y
		playerOrientation[5] = 0; // z
		
		alListenerf(AL_ORIENTATION, playerOrientation[0]); 
ChimDev
ChimDev

Solved, it was a simple mistake, I should have used alListenerfv instead of alListenerf, and not use playerOrientation[0], just playerOrientation

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.