SFML community forums
Help => Audio => Topic started by: kazyamof on October 18, 2016, 01:13:39 pm
-
Well, as always, spatialization audio is driving me crazy.
I can't found a good tutorial where this really works! I read a lot of answers on the forum, but I'm missing a step-by-step guide where some clear and simple information is presented. So I expected someone can answer me as simple as possible.
My cenario is:
Screen is 800x600.
My player moves on X screen. He spawns at Vector2(100, 500).
I wanna put a sound at Vector2(300, 500).
1 - What Position shoud I set to Sound? Vector3(300, 0, 500)?
2 - What Direction and Position I should set on Listener to make him hear the sound on right speaker while Player.Position.X < Sound.Position.X, and then on the left speaker when Player.Position.X > Sound.Position.X?
-
1 - What Position shoud I set to Sound? Vector3(300, 0, 500)?
Yes
2 - What Direction and Position I should set on Listener to make him hear the sound on right speaker while Player.Position.X < Sound.Position.X, and then on the left speaker when Player.Position.X > Sound.Position.X?
Vector3(Player.Position.X, 0, Player.Position.Y) for position.
The direction depends on where the player is facing. I'd say it should face negative Z to ear the sound as you describe it.
You see, nothing complicated ;)
-
You see, nothing complicated ;)
Finally is working with this set up and the Direction facing -Z.
Listener
.Direction = new Vector3f
(0,
0,
-1)
Thank you, I think I'm getting the audio's fell I want now.
This works for a platform game where -x/+x avatar's displacement fits with the 'logical' position of left/right speakers.
But what if I decide to make a topdown 2D game, where the avatar's receive rotations, I think this setup will not work anymore, right?
The avatar is rotated so the sound is on his left side, like the second section of this figure.
(https://s17.postimg.org/nuexy44f3/Sem_t_tulo.jpg)
How should I configure the Listener.Direction and Listener.VectorUp to this setup? Direction = Vector3(cos(90), 0, sin(90)) and VectorUp(0, 1, 0) ?
-
Actually, I had the "top down style" in mind when I answered you, so that should work the same way.