Camera Tilt Based on Movement

Hello! I’ve made a topic like this before but something about it feels… off? It only tilts left and right, and just kinda snaps in place, even with Tweens. I’d make one myself but I suck at coding. I want something that can work for both mobile AND PC. I’ve searched everywhere (DevForum, YouTube, even asking my coding friend [pending]) but to no avail.

Video Reference:

If anyone could give me a short script or some tips they used for this type of movement shown in the video, that would greatly help. Thank you very much in advance :hugs::hugs:

3 Likes

I found a great script for this a while ago,
(I forgot who made it but if I find the original post I’ll credit them)
It doesn’t rely on UserInputService which is good because that means it’s supported on multiple platforms and not just PC.
This is an edited version of the script I made to fit my needs for my game:

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

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

local rad = math.rad
local Rot = CFrame.new()

local function GetRollAngle()
	local Character = Player.Character

	if not Character then
		return
	end

	local Cf = Camera.CFrame

	return -Cf.RightVector:Dot(Character.Humanoid.MoveDirection)
end

RunService:BindToRenderStep("RotateCameraInDirectionPlayerIsGoing", Enum.RenderPriority.Camera.Value + 1, function()
	local Roll = GetRollAngle() * 2
	Rot = Rot:Lerp(CFrame.Angles(0, 0, rad(Roll)),0.075)

	Camera.CFrame *= Rot
end)

Edit:
I found the original post by @hashyyyyeryjrjej

24 Likes

I’ll test this out later, I’m on my phone rn, I’ll reply back to you when I get on my computer. Thanks in advance :hugs:

2 Likes

Hi again, if you’ve tested it did it work?

1 Like

this works and looks so nice! thank you!

This works wonders! Thank you very much :slight_smile:
I’ll be adding in another script so that it also does camera bobbing. Thank you again!

I only got to test it now since I didn’t have access to my computer