Need help making a camera like Apeirophobia

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? A camera tilt system like Apeirophobia.

  2. What is the issue? I really can’t find anything on how to do it and I have no idea how I would do it either.

  3. What solutions have you tried so far? I have looked all over dev forums and I want to try to do it on my own but I have no idea how.

Here is what I want to achieve: (with the thing where if you walk it titls too)

6 Likes

What you gonna do is get acceleration. I bet you know what that is. This is my theoretical script:

local Cam = workspace.CurrentCamera

local function GetRotationalCFrame(CFrame)
local x,y,z = CFrame:ToOrientation()
return Vector3.new(x,y,z)
end

local prevrotcf = GetRotationalCFrame(Cam.CFrame)
Cam.Changed:Connect(function()
local yacceleration = prevrotcf.Y-GetRotationalCFrame(Cam.CFrame).Y
-- set the cf I am not gonna do it cuz I am writing on devforum so its kinda hard.
end)
1 Like

i may or may not have a script for this if you want it

1 Like

Yeah, that would be amazing. I have been looking for a few hours :sweat_smile:

1 Like

Yes, I know what it is, though I don’t know how to do the cf part.

1 Like

gotta find it first
then test it if theres no bugs then there ya go

1 Like

Alright, you don’t know how much I appreciate this thank you :sweat_smile:

1 Like

How do I add camera sway? - Help and Feedback / Scripting Support - DevForum | Roblox

3 Likes

Thanks, though it feels really choppy. So idk.

1 Like

there ya go

-- made by shade :/

wait(0.1)

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()

local Character = LocalPlayer.Character

if not Character then
	Character = LocalPlayer.CharacterAdded:Wait()
end

local Humanoid = Character.Humanoid
local HumanoidRootPart = Character.HumanoidRootPart
local Camera = workspace.CurrentCamera

local Val = 0 -- this part may look ugly but it gets the job done
local Val2 = 0
local Val3 = 0
local Val4 = 0
local Val5 = 0
local Val6 = 0
local Int = 10
local Int2 = 10
local vector3 = Vector3.new()

lerp = function(a, b, c) -- i love lerp
	return a + (b - a) * c
end

RunService.RenderStepped:Connect(function(DT)
	DT = DT * 60

	local magnitude = HumanoidRootPart and Vector3.new(HumanoidRootPart.Velocity.X, 0, HumanoidRootPart.Velocity.Z).Magnitude or 0
	local magnitude2 = math.min(magnitude, 30)

	if DT > 3 then
		Val = 0
		Val2 = 0
	else
		Val = lerp(Val, math.cos(tick() * 2 * math.random(10, 15)) * (math.random(5, 20) / 200) * DT, 0.05 * DT)
		Val2 = lerp(Val2, math.cos(tick() * 2 * math.random(5, 10)) * (math.random(2, 10) / 200) * DT, 0.05 * DT)
	end

	Camera.CFrame = Camera.CFrame * (CFrame.fromEulerAnglesXYZ(0, 0, math.rad(Val3)) * CFrame.fromEulerAnglesXYZ(math.rad(Val4 * DT), math.rad(Val * DT), Val2) * CFrame.Angles(0, 0, math.rad(Val4 * DT * (magnitude2 / 5))) * CFrame.fromEulerAnglesXYZ(math.rad(Val), math.rad(Val2), math.rad(Val2 * 10)))

	Val2 = math.clamp(lerp(Val2, -Camera.CFrame:VectorToObjectSpace((HumanoidRootPart and HumanoidRootPart.Velocity or Vector3.new()) / math.max(Humanoid.WalkSpeed, 0.01)).X * 0.08, 0.25 * DT), -0.25, 0.2)

	Val3 = lerp(Val3, math.clamp(UserInputService:GetMouseDelta().X, -5, 5), 0.25 * DT)
	Val4 = lerp(Val4, math.sin(tick() * Int) / 5 * math.min(1, Int2 / 10), 0.25 * DT)

	if magnitude > 1 then
		Val = lerp(Val, math.cos(tick() * 0.5 * math.floor(Int)) * (Int / 200), 0.25 * DT)
	else
		Val = lerp(Val, 0, 0.05 * DT)
	end

	if magnitude > 12 then
		Int = 20
		Int2 = 18
	elseif magnitude > 0.1 then
		Int = 12
		Int2 = 14
	else
		Int2 = 0
	end

	vector3 = lerp(vector3, Camera.CFrame.LookVector, 0.125 * DT)
end)
4 Likes

It works! Also is smooth and satisfying. Thank you so much! :smiley:

3 Likes

variables all over the place…
Looks decompiled

1 Like

my friend said the same thing eariler when he wanted a better camera bob

This is very good although, for me it shakes alot when i’m standing still, does that happen to you?
Do you know why this happens, what the variables for it is or anything that causes this.

no he does not know (because it’s decompiled) but I am guessing it’s from when magnitude is less than 1, so Val (funny name for a variable right) gets lerped with deltaTime etc

3 Likes

I found that out aswel, script looked kinda suspicious too. Thanks

it’s not decompiled???

dont know where you got that from.

Maybe because this entire line of (decompiled) code is nearly 1:1 to yours except for a few variable names? Don’t steal code and claim it as your own.

7 Likes

To add on, if it wasn’t decompiled they should know what variables mean not just to be “trusted” with them.
I could be wrong here, but yeah.

2 Likes

Went into the game and decompiled it myself, just as you did, except you took credit for the making of the code.

6 Likes