How would I make vehicle sound pitch change with vehicle acceleration?

Hi, How would I make vehicle sound pitch change with vehicle acceleration?

Do I link it to my chassis? for example cylindrical constraints? or do I link it to the seat?

How would I go about doing this?

Any help is much appreciated! :grinning: :+1:

Realistically you’d link the sound pitch with the engine, but there’s no actual engine unless… so we assume the speed of the wheel is equal to the speed of the engine which is close and simple enough.

You could also instead of measuring the velocity of the wheels measure the velocity of the vehicle seat like in most free models, however the issue is if the car falls off the baseplate the velocity gets real high and annoying.

As for how the pitch changes the most basic is a linear formula like this one I found off a model:

engineSound.PlaybackSpeed = (speed + engineSoundRatio) / engineSoundRatio

It’s just a linear increase formula, speed increases, pitch increases. Graphing it out:

Overall functions I used you might find helpful, make sure to adapt for your case.

local function getAngularVelocity(wheel)
	return wheel.RotVelocity:Dot(wheel.CFrame.rightVector)
end

local function measureWheelVelocity()
	local wheelRadius = wheelParts[1].Size.Y / 2
	local averageAngularVelocity = 0
	for i, v in pairs(wheelParts) do
		averageAngularVelocity += getAngularVelocity(v)
	end
	averageAngularVelocity = averageAngularVelocity / #wheelParts
	local wheelVelocity = averageAngularVelocity * wheelRadius
	return wheelVelocity
end

local engineSoundRatio =  40

--in your update loop somewhere to constantly change playback speed
local speed = math.abs(measureWheelVelocity()) --same as seat velocity but doesnt spaz when car falls
engineSound.PlaybackSpeed = (speed + engineSoundRatio) / engineSoundRatio
2 Likes

Pretty sure the roblox sound system already accommodates for doppler shifts, if that is what you want to accomplish