Hi guy, how do you set diameter for sound component. For example, if the player stay alway from the source of the sound, he wouldn’t hear it.
Another question, how do you set volume for sound component?
Regards
You can use go.set(url, "gain", 0.5)
on your component.
As for fading out depending on distance, using a value between 0.0
and 1.0
. Here’s an example of using a circle radius
local max_distance = 200 -- where the value should be 0
-- distance between objects
local distance = vmath.length(player_pos - sound_pos)
-- make it into unit range [0.0, 1.0] (0.0 closest to player)
local unit_value = distance / max_distance
-- to make it do what we want:
-- 1.0 at the players position, and 0 at the edge of the radius
unit_value = 1.0 - unit_value
if unit_value < 0 then
unit_value = 0 -- make sure it stays at 0 beyond the circle radius
end
4 Likes
Great, thank you for your help.
3 Likes