How can I re-create this camera effect?

Hello Everyone! I was so long thinking about how I can re-create this camera effect. Timecode: 00:20 - 00:28.

And then I started learning it, and I understand how to do it. But my question is how I can do it when I’m looking at something and how I can make so it would be gradually glitching more and more like on the video. Or just like in random time it will glitch for 2 seconds and then stops.

I already made something that I using in my game using CFrame.Matrix (like in the video says).
There is my code example that I’m already using BUT, for other use:

local twInfo = TweenInfo.new(
	.55, Enum.EasingStyle.Cubic,
	Enum.EasingDirection.Out,
	0, false, 0
);
local twservice = game:GetService("TweenService")
local function tw(t,inf,p)
	local tween = twservice:Create(t,inf,p) return tween
end
local squishX = script:FindFirstChild("SquishX")
local squishY = script:FindFirstChild("SquishY")

local function squishFunction(valueX: number, valueY: number)
	local twSquishX = tw(squishX, twInfo, {Value = valueX}):Play()
	local twSquishY = tw(squishY, twInfo, {Value = valueY}):Play()
end; squishFunction(1, 1)
local runService = game:GetService("RunService")
runService.RenderStepped:Connect(function()
	local cf = CFrame.new(0, 0, 0, squishX.Value, 0, 0, 0, squishY.Value, 0, 0, 0, 1)
	camera.CFrame = camera.CFrame * cf
end)

Please, don’t copy my example code if you’re not helping me.

So, yeah. If anyone can answer my question or give some tips how I can do this, that would be really appreciated! Thanks.

5 Likes

Can you add details on what are squishX and squishY variables are for?

local squishX = script:FindFirstChild("SquishX")
local squishY = script:FindFirstChild("SquishY")

It’s a two number values that contains in local script.

well to get the intensity with the more damage like shown in the video, you can multiply the squishX.Value and squishY.Value in the render stepped thing

local healthIntensity = 0
--calculate this value based on how much health the player has
--your range can be whatever, zero to one works very fine, but if you always want some glitchy effects you can make it like 0.1-1 or smth

local randIntensity = 1
--make this a value like one when there is no random glitching
--and 2 when you've got a lot of random glitching

--lets say you needed another factor, just add another
local idkIntensity = 1

runService.RenderStepped:Connect(function()
	local calculatedIntensity = healthIntensity * randIntensity * idkIntensity
	--calculate our intensity for this frame, multiply all the intensity factors

	local cf = CFrame.new(0, 0, 0, squishX.Value * calculatedIntensity, 0, 0, 0, squishY.Value * calculatedIntensity, 0, 0, 0, 1)
	--when calculating our CF we can multiply the squish values by the calculated intensity values
	camera.CFrame = camera.CFrame * cf
end)

however for “making it more glitched when the player looks at the guy” you would need a health value, check if slenderman is in the player’s view, whether with dot product calculations or with Camera:WorldToViewportPoint

although I would suggest dot products to make it not relative to your camera size

1 Like

It’s just giving me black screen, and that’s all.

:man_facepalming:
I forgot if have the cframe from 0-1 then it will end up making the distortion zero

add one to the squishX and squishY values. and update the values they’re set to in the code accordingly

local cf = CFrame.new(0, 0, 0, 1 + squishX.Value * calculatedIntensity, 0, 0, 0, 1 + squishY.Value * calculatedIntensity, 0, 0, 0, 1)

Ok, so how I can make a glitching like on video? Because my main question is how to make glitching. Also it’s working now.