Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

1 comment

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

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!

1 comment

0

I have never done vehicles before so it would really help if you tell me the mistakes if I have any

This discussion is preserved as it was. New answers, comments, and votes are closed.