FOV depending on PlaybackLoudness of a sound?

Hello! My name is Isaak and I’m a new scripter! I’ve been trying out some new things with PlaybackLoudness like volume and size, but there’s one thing I’ve been looking for but can’t find.

How do I make the FOV zoom in when the PlaybackLoudness value gets higher? I know how to make it zoom out but not zoom in.

Hi,

you can change workspace.CurrentCamera.FieldOfView to make what you need, its kinda easy, you can use a localscript on StarterGui if you want to. :slight_smile:

I know! I know all of those things, this is how you make the FOV zoom out depending on the PlaybackLoudness;

game.Workspace.Camera.FieldOfView = Sound.PlaybackLoudness/10

But I’m trying to get it to zoom IN, not out. How do I do that?

1 Like

instead of “/”, use “*” to multiply it, be careful with this because it may look weird

2 Likes

If youre trying to make the FOV smaller (make it look like it’s zooming in), then youre going to need to subtract the original FOV from the playbackLoundess

local originalFOV = workspace.CurrentCamera.FieldOfView
workspace.CurrentCamera.FieldOfView = originalFOV - Sound.PlaybackLoudness/10

obviously you’re going to need to make this code execute all the time to update the FOV constantly so (if you havent already) use a RenderStepped event.

The code would look something like this

RS = game:GetService("RunService")
local originalFOV = workspace.CurrentCamera.FieldOfView

RS.RenderStepped:connect(function()
       workspace.CurrentCamera.FieldOfView = originalFOV - Sound.PlaybackLoudness/10
end)

The method that TDtheTV pointed out will unfortunately not work since multiplying the playback loudness will only make the FOV have an even more “zoomed out” effect.

2 Likes

Hi, best way to do that imo is to get a multiplier.

local DEFAULT_FOV = 70
local MAX_PLAYBACK_LOUDNESS = 200 -- May need to change for individual sounds


RunService.RenderStepped:Connect(function()
	camera.FieldOfView = DEFAULT_FOV - (DEFAULT_FOV * math.clamp(playbackLoudness / MAX_PLAYBACK_LOUDNESS), 0, 1))
end)

Consider 0-1 a percentage. If the max playback loudness is achieved then it will zoom in completely, you can modify the clamp min/max to change the max zoom.

1 Like

your method is correct enqrypted, actually, your right, im kind new with playbackloudness as well.

also you created insanity so… xd

1 Like

Be careful with this method. PlaybackLoudness is a value ranging from 0-1000. The FOV is usually 70, so this will cause issues if the loudness exceeds 700. You also don’t have proper control over the max zoom

1 Like

Thank you all for helping!

30 Characters