basically, i have this “motion blur” script that detects if the CFrame moves by ANY movement:
local blurness = 5 --//how blurry the motion blur should be, which is the BlurEffect's size
workspace.CurrentCamera:GetPropertyChangedSignal("CFrame"):Connect(function()
local motionBlur = Instance.new("BlurEffect", game.Lighting)
motionBlur.Size = blurness
game:GetService("Debris"):AddItem(motionBlur, 0) --// zero doesn't delete it instantly, it's just the lowest amount of time possible
end)
the problem is, it detect any movement, but it being motion blur, thats not how motion blur works, is there a way to detect if it moves by a number or vector3?
You could implement sanity checks for every time the CFrame changes to check if the Position/X/Y/Z values are what you want them to be?
local blurness = 5 --//how blurry the motion blur should be, which is the BlurEffect's size
workspace.CurrentCamera:GetPropertyChangedSignal("CFrame"):Connect(function()
local CamPosition = workspace.CurrentCamera.CFrame.Position
if CamPosition.X > 50 then
local motionBlur = Instance.new("BlurEffect", game.Lighting)
motionBlur.Size = blurness
game:GetService("Debris"):AddItem(motionBlur, 0) --// zero doesn't delete it instantly, it's just the lowest amount of time possible
end
end)
Save the current CFrame in a variable in the script, and check how much it moved by a bit of math, if its greater then a certain number, then motion blur it?
local currentCamera = workspace.CurrentCamera
local CamVector3 = workspace.CurrentCamera.CFrame.Position
local blur = game.Lighting:WaitForChild("Blur")
local runService = game:GetService("RunService")
runService.Heartbeat:Connect(function()
local result = CamVector3 - CamVector3
if result >=5 then
game.Lighting:WaitForChild("Blur").Size = 10
end
end)
i get this error: Players.F0xBirdman.PlayerScripts.LocalScript:7: attempt to compare number and Vector3
on the side, i noticed this: while wait() do print(CamVector3) end prints the same position over and over, even with the camera moving
Um, that’s not what I meant, when it changes compare the two values and see how much it changed by, if it’s greater then 5 or whatever then set the camvector3 once the comparison is done.
local currentCamera = workspace.CurrentCamera
local CamVector3 = workspace.CurrentCamera.CFrame
local blur = game.Lighting:WaitForChild("Blur")
local runService = game:GetService("RunService")
CurrentCamera:GetPropertyChangedSignal("CFrame"):Connect(function()
local result = CurrentCamera.CFrame - CamVector3
if result >=5 then
game.Lighting:WaitForChild("Blur").Size = 10
end
CamVector3 = CurrentCamera.CFrame
end)
im aware thats not what you meant, thats why i said “im stuck”; anything ive tried i get the same error or similar Players.F0xBirdman.PlayerScripts.LocalScript:7: attempt to compare number and Vector3
noticing that you edited your post to a script, same error i have been getting. this was my latest attempt:
local currentCamera = workspace.CurrentCamera
local CamVector3 = workspace.CurrentCamera.CFrame.Position
local blur = game.Lighting:WaitForChild("Blur")
local runService = game:GetService("RunService")
workspace.CurrentCamera:GetPropertyChangedSignal("CFrame"):Connect(function()
local result = currentCamera.CFrame.LookVector - currentCamera.CFrame.LookVector
if result >=5 then
game.Lighting:WaitForChild("Blur").Size = 10
end
end)
Simple! Each RenderStep, get the delta (change) of the CFrame since the last frame. Then, assemble it into one number (you can do this multiple different ways) and assign the blur effect to that number.
I would give a code example but I’m on mobile right now…
Well I’m going to try anyways.
local RunService = game:GetService("RunService")
local Lighting = game:GetService("Lighting")
local Camera = workspace.CurrentCamera
local BlurEffect = Lighting:WaitForChild("Blur")
local lastCameraCframe = Camera.CFrame
RunService.RenderStepped:Connect(function()
local RotDifference = (Camera.CFrame:ToOrientation() - lastCameraCframe:ToOrientation()).Magnitude
lastCameraCframe = Camera.CFrame
BlurEffect.Size = RotDifference * 3
end)
local RunService = game:GetService("RunService")
local Lighting = game:GetService("Lighting")
local Camera = workspace.CurrentCamera
local BlurEffect = Lighting:WaitForChild("Blur")
local lastCameraCframe = Camera.CFrame
RunService.RenderStepped:Connect(function()
local v3 = Vector3.new
local RotDifference = (v3(Camera.CFrame:ToOrientation()) - v3(lastCameraCframe:ToOrientation())).Magnitude
lastCameraCframe = Camera.CFrame
BlurEffect.Size = RotDifference * 3
end)
GetPropertyChangedSignal doesn’t fire for fast changing properties like CFrames and Positions except when you change them explicitly.
If you want to check how much the camera moved from it’s starting point, you can get just simply get the distance from it’s starting point to it’s current:
local startingCamPos = workspace.CurrentCamera.CFrame.Position -- get the position at starting point
game:GetService("RunService").Heartbeat:Connect(function()
local distance = (startingCamPos - workspace.CurrentCamera.CFrame.Position).Magnitude
if distance > = 5 then
game.Lighting:WaitForChild("Blur").Size = 10
end
end)