how can I make that the wind is not heard in the building but it can be heard outside (like in this game)?
There’s quite a few different methods for doing this.
One way is to detect whenever the humanoid moves to another floor material and then get what the humanoid is currently standing on.
So if the floor of the house is made of wooden planks, you stop the sound for the player whenever the humanoid.floormaterial is woodplanks.
Another method is to fire a ray downwards (or upwards if you like) from the player after a specific set of time and find whatever is below (or above) the player. So if the ray hits, say the floor, you can stop playing the sound for that player as he’s indoors.
Intro to Raycasting
(Although personally I’d prefer method 1)
Yes, but there, even if standing in the bus, move the camera out of the window to the street, the wind will be heard. Visit this game
In that case, you could get the cameras current position
workspace.CurrentCamera.CFrame.Position , then raycast downwards (or upwards) from the camera position every frame using
RunService.RenderStepped to check what part the ray hits. And if the part the ray hits is considered to be inside, stop playing the sound.
i don’t understand. help pls
The way the system works is by using raycasting, as @amadeupworld2 mentioned already. Here is a basic example of how to do a raycast from the camera:
-- This is a LocalScript in StarterPlayerScripts -- local cam = workspace.Camera game:GetService("RunService").Heartbeat:Connect(function() local rayResult = workspace:Raycast(cam.Position, Vector3.new(0, 1, 0) * SOMEDISTANCE) -- Casts straight upwards to find a ceiling if rayResult then -- Indoors -- else -- Probably outdoors -- end end)
I’m not sure how Bus Simulator specifically does their dynamic sounds, but I do know that some games (like Celeste shown here) use some sort of low-frequency EQ effect when you’re underwater. This might be able to give you the ability to continue using the same sound for the inside with an added muffling effect. If you add an
EqualizerSoundEffect object to a
Sound object, you can adjust the HighGain, MidGain and LowGain until you get audio that sounds like you’re inside. From there, you could use TweenService to animate your
EqualizerSoundEffect's high/mid/low gain properties to their appropriate values. If you don’t want to use TweenService, you can just set them directly just like you would normally with properties.