I’m looking to create a semi-dynamic camera system with effects for moving, jumping, sprinting, ect. I’ve made good progress but I’ve run into an issue. I made the camera do a little dip once the character lands after being in the air, and I found a bug shortly after in which the camera would dip based on where the camera was facing rather than a flat dip.
I don’t often work with CFrames so I’m a bit confused and all tutorials use a bunch of technical mumbo jumbo I find hard to understand, so some help would be appreciated.
The issue:
https://streamable.com/trihj5
Upon landing the camera will dip a little to show the force of the landing, however if you tilt your camera all the way down the dip seems to go backwards instead of downwards.
Some extra stuff to show how it interacts with the rest of the game:
https://streamable.com/nx8c5h
Variables
local cam = workspace.CurrentCamera
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart")
local head = char:WaitForChild("Head")
Code
bob(off:Lerp(CFrame.new(0,off.y - (math.abs(root.Velocity.Y) / 16),0),0.4))
This is the code for the camera bob, the function “bob” is displayed below.
Functions
local function bob(data)
if data then off = data
cam.CFrame = cam.CFrame * off
end
end
There’s a renderstepped loop that repeatedly lerps the “off” variable with the bob function which sets the camera dip back to where it started.
Help would be appreciated, thanks!