I'd like resources or and advice on how to manipulate a camera to do something similar to the following: -The camera to zoom out slightly when the player is sprinting
I am not familiar with manipulating cameras so any advice or resources would be very appreciated
Thank you
In order to achieve that you can use something called 'TweenService'
which does smooth
transitioning between anything really. It's a very neat service ROBLOX has. You can use TweenService on things such as:
A number
A bool value
A CFrame
A Rect
A Color3
A UDim
A UDim2
A Vector2
A Vector2int16
A Vector3
More on TweenService
The second thing we will use is the property of the player's camera called 'FieldOfView'
which "sets how many degrees in the vertical direction (y-axis) the camera can view. Uniform scaling is enforced meaning the vertical and horizontal field of view are always related by the aspect ratio of the screen. This means the FieldOfView property also determines the horizontal field of view".
This FieldOfView property, when modified, will give the illusion of zooming out/in.
I was bored so I did most of the work for you:
local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local TweenService = game:GetService("TweenService") local tweenInfo = TweenInfo.new( 0.5, -- how long it takes to tween Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, -- will it repeat? If below 0 it will go forever false -- will it reverse? True or false ) local LocalPlayer = Players.LocalPlayer repeat wait() until LocalPlayer.Character local Camera = workspace.CurrentCamera local shiftDown = false UserInputService.InputBegan:Connect(function(input, gameProcessed) if input.UserInputType == Enum.UserInputType.Keyboard and not gameProcessed then if input.KeyCode == Enum.KeyCode.LeftShift then shiftDown = true local goal = {FieldOfView = 100} local tween = TweenService:Create(Camera, tweenInfo, goal) tween:Play() --Zoom out --Make the player run -- simple but I dont wanna do the whole thing for you end end end) UserInputService.InputEnded:Connect(function(input, gameProcessed) if input.UserInputType == Enum.UserInputType.Keyboard then if input.KeyCode == Enum.KeyCode.LeftShift then shiftDown = false local goal = {FieldOfView = 70} local tween = TweenService:Create(Camera, tweenInfo, goal) tween:Play() --Zoom in --Make the player stop running -- simple but I dont wanna do the whole thing for you end end end)
Fun fact: The default camera FieldOfView is 70
Anyways hope I helped, please let me know if you have further questions!