Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I want the screen to "zoom out" when the character moves fast. How do I do this?

Asked by 3 years ago

I'm making a racing game, and I want the FOV to zoom out a tiny bit when the vehicle moves fast. How do I do this?

(I'm still a newbie)

2 answers

Log in to vote
0
Answered by
pwx 1581 Moderation Voter
3 years ago

FieldOfView is a property of the Camera.

local Players = game:GetService('Players')

local Camera = workspace.CurrentCamera
local Player = Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

local runningSpeed = 30

while true do
    wait(.1)
    local humanoidRootPart = Character:FindFirstChild('HumanoidRootPart')
    if humanoidRootPart then
        local hrpVelocity = humanoidRootPart.Velocity.magnitude
        if hrpVelocity > runningSpeed then
            Camera.FieldOfView = 90 -- zooms out camera
        else
            Camera.FieldOfView = 70 -- default view
        end -- speed check
    end -- a check for base part, we're using this to detect how fast a player is moving
end -- while true do

You can also use TweenService as a way to smoothly move the camera in/out between walking and running.

0
While this did make the camera zoom out, what I wanted it to do was smoothly zoom out a bit, like in NFS Heat. https://www.youtube.com/watch?v=OgXdurfLSFs in this video, you can see that the faster the car goes, the camera zooms out nesnotnAGamesHD 2 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

There is a property of the camera called FieldOfView this property is a value (which means number of any kind)

To change the FOV you must write this in a local script

local Camera = workspace.Camera

while true do
if --[[vehicle speed variable/directory goes here]] >= --[[the normal speed of the vehicle in numbers goes here]] then
Camera.FieldOfView.Value = 90 --you can put a different value this is just what I am doing
wait(0.1)
end

please tell me if I made any mistakes, I hope this helped!

0
I have never done vehicles before so it would really help if you tell me the mistakes if I have any MarcTheRubixQb 153 — 3y

Answer this question