How to make a realistic flyby/doppler effect?

The car passing by in these videos:

I tried to do that by placing a script inside ServerScriptService using SoundService.DopplerScale, but it doesn’t work.

6 Likes

don’t know if this would be realistic but you could change the volume depending on how much the magnitude is

1 Like

Do I have to it locally? Because I don’t know how to get all the sound children via script.

You’d use a LocalScript that alters sound pitch based on relative velocity to the Camera, most likely.

6 Likes

DopperScale works, but IIRC it uses the Camera.Focus point to determine listener position, not the position of your avatar’s head. That might be the issue here.

1 Like

You say it ‘doesn’t work’ but can you describe what that means? What does it do? Are you moving a part with a sound in it past the player? What are you attempting to do exactly and how have you attempted to do it and what are the results you are getting?

as far as I observed, the script I made using SoundService.DopplerScale didn’t make a difference to the sounds and I’m attempting to make the doppler effect that you see in the 2 videos I used as an example. I’m really new to SoundService, so I don’t really know what I’m doing.

Okay, but what moves the sound past the listener? Is it a vehicle that another player is driving?

Do you hear any sound, is it 2d or 3d sound?

Assuming you are using a 3d sound (parented by a part) it seems the sound RollOffMode should do what you are expecting:

https://developer.roblox.com/en-us/api-reference/property/Sound/RollOffMode

1.Basically anything as long as it passes by the listener.
2.3d sound

Are you saying sound’s volume doesn’t reduce as the distance increases? If so, that would imply to me that the sound is 2d(not parented by a part)

I’m not sure, but this is how it sounds like, and it seems off for some reason.

2 Likes

I think the effect is similar to the real world example you gave. The car in your game was closer to begin with so maybe thats why it didn’t fade in as much. And the downshifting of the gears made the rpm sound slower. I think it sounds pretty good in your vid.

If you want to enhance the fade in and out into the distance (for all 3d sounds) you could try setting this:

local SoundService = game:GetService("SoundService")
SoundService.RolloffScale = 1 -- attenuation simulates real world
SoundService.RolloffScale = 2 -- sound attenuates twice as fast as the real world

Maybe this will be more noticeable than changing the doppler setting.

Another thing that the real world example has that your roblox car doesn’t is the exhaust in the back. So that is another reason why the sound is different after the car passes in the real world example. If you’re looking for a noticeable pitch shift from rapidly passing sounds, i’m not sure how that could be done.

Edit:
I did some experimenting with this on a baseplace with a motor sound. I was able to reproduce the effect but, it required subtantial doppler exaggeration:
SoundService.DopplerScale = 6

I also set SoundService.RolloffScale = 2

And this gave a fairly satisfying result. However I think if you were to use these settings you would get strange pitch shifting of 3d music or other sounds where it would be unwanted. (for example if you rotate your camera view around and a 3d music is playing nearby you’d get noticeable pitch warping of the music as the camera moves.)

This is how I tested the effect, by a stationary motor sound and zooming way out and rotating my camera past the motor sound. It was a cool effect but I don’t think it would be worth it if it messes up ‘regular’ sounds.

5 Likes

It sounds a little accurate now

Now setting the doppler to 6 makes it even more accurate!

3 Likes

Yep, that’s where I found it noticable enough, when i got to 6. But who knows what strangeness will happen to music if you leave it there. :slight_smile:

Try it by zooming out and rotating with the arrow keys where the horn goes under your camera, you can get smoother passes to hear the shift.

1 Like