I want to make spatial sound…but it doesn’t work on my situation. In this example(GDevelop 5) It says like they devided with 100 cuz its 800x800 but i can’t understand why we have to devide it. And I think the spatial sound doesn’t work on my situation because of the resolution size or because I make the sprite size differently. What should I write in to values with different situations? Can anyone explain about the spatial sound in detail?
There’s a brief explanation on spatial sound in the GDevelop wiki - have you checked it?
Spatial sound take 3 parameters - x, y & z. In the example, x and z are set, and not y. Make sure you’re doing the same:
Is this right? I want to make if the player is in range play spatial sound, and if the player is out of distance stop playing sound. But it doesn’t work. I tried /100 too but this doens’t work eitehr. And How can i set the custom distance of the spatial sound?
Just think about the numbers, and what this part of the wiki:
Set position of sound
Sets the spatial position of a sound. When a sound is at a distance of 1 to the listener, it’s heard at 100% volume. Then, it follows an inverse distance model . At a distance of 2, it’s heard at 50%, and at a distance of 4 it’s heard at 25%.
You’re using straight X & Y position of character. It could be anywhere, and the co-ordinates could be 1000,1000. That’s effectively 0 volume.
I think what you’re after is a range of numbers from 6 to 1, quietest to loudest, depending on the closeness to NewSprite. So 600 pixels away would be a 6 setting, and almost on top of the sprite (less than 100) would be a 1.
The formulas you’ll want to use are:
X position of listener = abs(NewSprite.X() - Footprint_Player.X()) / 600
Z position of listener = abs(NewSprite.Y() - Footprint_Player.Y()) / 600
abs returns the absolute value - it ignores any negative signs, and makes the number positive (greater than 0).
The division is not strictly necessary for all directional sound, it just makes sense in this case. The further away you are from sound, the less you can hear it. If you are too far from it, it is not audible anymore. That distance is very low - a few meters (x, y and z are typically in meters) of distance and already you stop hearing the sound. If you just use the objects positions, then moving even just 10 pixels is like moving 10 meters away from the sound source.
The division allows to map values from that huge range to a smaller one: “0/800 → 0”, “800/800 → 1”, “400/800 → 0.5”… That way, 800 pixels of distance on screen is like 1 meter of distance audio-wise, instead of 800.
There is an x, y and z axis as directional sound works in 3D space. Just like in GDevelop, the X describe how much left / right a sound is, and the Y how much up / down it is. The Z order, depth, tells you how much in front / behind you a sound is.
The example doesn’t need sound to be above or below the listener, so the Y is left to 0. Since the front and behind is defined by the 2D Y axis, it is used for the Z value, and left and right is X both in the 2D and 3D coordinate space.
Thx for replying:) Im wondering how to make the formula of the listeners position…Can u help me with this? Cuz spatial sound doesn’t work in my project…Is this because of the formula or something else?
Its resolution is 1920x1080 and I resized the sprites more smaller than original one
Have you tried:
I can’t see that in that last event of your screenshot; which, btw, will only get executed once at the start of the scene, so you’ll need to sort that out.
thx for replying:)Uhh the formulas which u gave me doesn’t work…and idk What should i do…
Edit: This is the example I found on forum and I dont know why they set position of the sound once more. Can u explain it?
These example works.
And this example this set postition of listener seperately and if i change, it doesn’t work…
I just started gdevelop since last month…so i dont know much about it…thx for helping me:)
What do you expect if you change the object you are checking the distance with in the condition but not the action?
Here’s what you had earlier:
And you’ve replaced NewSprite with sound in the condition, but not the action.
@arthuro555 im making a 3D horror game and i must have 3D sounds for it
how do i do it ? i mean i used the in engine spatial sound but that only counts the position, not the listeners angle.