-
What do you want to achieve?
I want a heartbeat FOV effect that gets bigger as the player gets closer to an NPC, sort of like this video: How to Create a Heartbeat Effect in Adobe Premiere Pro CC - YouTube
I already have a heartbeat sound effect, and I’d like the sound and FOV to be in sync with each other. -
What is the issue?
I don’t know how to program really well, so I’d appreciate someone to give advice for this (please walk me through it like a baby since I’m pretty bad at programming still). If you have any ideas how this system would work let me know! -
What solutions have you tried so far?
I haven’t really tried anything yet since I can’t think of any ideas, I also didn’t really find anything relevant on the forum. I was thinking maybe a script can quickly change the clients FOV with tweens, but I don’t know how you could make this become bigger as you get closer to an NPC. (And again I’m not a good scripter)
you could make the heartbeat sound just one beat and have it repeat twice so that you dont have to rely on timing to get them to sync, for the FOV its just using TweenService on the LocalPlayer’s camera im p sure
pp lighting fx specifically a hue modifier can get you that shade of red during the beat as well, same can be accomplished thru tweening
Thanks for the suggestion, I’ll look into it!
You can use Player:DistanceFromPlayer(NPC)
then change around the FOV if the player is too close to the npc.
(This should be a local script)
local FOV = 70
while wait() do
local DistanceFromPlayer = Player:DistanceFromPlayer(NPC:GetPivot().Position)
FOV = MaxFOV - DistanceFromPlayer
game.ServerStorage.FOV.Value = FOV
end
The only thing that is bad is that it only check once, that’s why we have to use a loop to keep on updating it. You could use an NumberValue and change the value locally. Here’s another example.
local Camera = game.workspace.CurrentCamera
local FOV = game.ServerStorage.FOV
local Heartbeat = --Heartbeat sound
While true do
local TI = tweeninfo.new(SpeedOfHeartBeat)
game:GetService("TweenService"):Create(Camera, TI, {FieldOfView = 70}):Play()
Heartbeat:Play()
wait(SpeedOfHeartBeat)
Local TI = tweeninfo.new(SpeedOfHeartBeat)
game:GetService("TweenService"):Create(Camera, TI, {FieldOfView = FOV.Value}):Play()
Heartbeat:Play()
wait(SpeedOfHeartBeat)
end
(btw don’t expect the script to work because I am on mobile rn)
Thanks a lot, this is really helpful! I appreciate that you wrote an example script and explained it, I’ll also use this as a reference to make the system
Made a slight mistake, use replicatedstorage instead of server storage because it can’t be accessed by the client