Hello,
I’m working on an FPS game, and have made a small FOV changing local script in StarterPlayerScripts, that if you fall down, your FOV increases up, and when you land then it goes back to the original FOV.
However I do not know how to move the current camera, position or orientation, I want it like if you land, the camera jolts downwards (using orientation) then goes back to normal orientation.
I tried searching up how to do these stuff but I don’t understand a thing, or didn’t really find any tutorials
Could someone help me how to do these camera movement effects? Would be much appreciated.
local players = game:GetService("Players")
local ts = game:GetService("TweenService")
local player = players.LocalPlayer
local function x(char)
local humanoid = char:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local originalFOV = camera.FieldOfView
local FOVincrease = originalFOV + 20
local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local isFalling = false
local function tweenFOV(target)
local tween = ts:Create(camera, tweenInfo, {FieldOfView = target})
tween:Play()
end
humanoid.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Freefall then
if not isFalling then
isFalling = true
tweenFOV(FOVincrease)
end
elseif newState == Enum.HumanoidStateType.Landed
or newState == Enum.HumanoidStateType.Running
or newState == Enum.HumanoidStateType.RunningNoPhysics then
if isFalling then
isFalling = false
tweenFOV(originalFOV)
end
end
end)
end
if player.Character then
x(player.Character)
end
player.CharacterAdded:Connect(x)