How to make a sound play when hitting the floor?

I want to achieve that a sound plays when the obj (object) falls on the ground…

and as bigger as the obj is as louder the and slower the sound plays… or as smaller the obj is

that it plays the sound faster and quieter

i have 2 parts… obj1 (the smaller one) and obj2 (the bigger one)

obj1:

  • plays the sound quick and quiet

obj2:

  • plays the sound slow and loud
2 Likes

I have not done this before and neither do I have time to experiment this at the moment, but there is probably a possibility to obtain the object’s size and use it to calculate the .Volume and .PlaybackSpeed of the sound.

--//This is just an example sketch

fallingObjectSize = object1.Size.X + object1.Size.Y + object1.Size.Z

sound.Volume = fallingObjectSize --//Do calculations to find a good balance between size and volume
sound.PlaybackSpeed = fallingObjectSize --//Same here
sound:Play()

For the .Volume, make a calculation that determines the bigger the total size of the object is, the louder it plays, and do the opposite for .PlaybackSpeed, making it slower the bigger it is.

4 Likes

you could do something like this

local function calculateValues(targetPart: BasePart)
	local alpha = 0.05 -- Play around this with value for desired result
	local sizeMagnitude = targetPart.Size.Magnitude * alpha
	
	return sizeMagnitude, (1 / sizeMagnitude)
end

local volume, playbackSpeed = calculateValues(part here)
print(volume, playbackSpeed)
2 Likes

The previous answers are pretty good, but you should account for the mass of the part too in addition to size and speed.

1 Like