I want to make system where depended on camera position different sound will play like in this video I just want to know the right technique
robloxapp-20200820-1503238.wmv (3.6 MB)
idk the best way to do this, but one way is to check the camera’s position in an infinite loop to see if it’s in an area with a custom sound, then play that sound on clientside (a local script). The sound needs to be outside a part, like in a folder in workspace to have the volume consistent regardless of where the camera is.
how to check if a position is in an "area"
I would store an array of “areas” formatted like:
{
[1] = { -- A square that extends infinitely upwards and downwards that has a corner at x=0, z=0 and one at x=10, z=10
0, 0,
10, 10
},
[2] = { -- square with corners at Vector3.new(8,0,16) and Vector3.new(16,0,24)
8, 16,
16, 24
}
}
Then, in the infinite loop, check if the camera’s position, Camera.CFrame.Position
, is >
the smaller position and <
the greater position of each area to see if it’s in the area
You might need to add a Y value for each of your areas if you want to consider the camera going above a building and playing the outside sounds though
2 Likes