I’m working on an effect for a game, I am using viewportframes to fake a motion blur type effect. I want to have them update at fixed intervals, which works fine but I want to make each individual viewport update after the previous one. Currently since they all update at the same time it just makes it look like you are running at a low frame rate.
Here is my code
local increment = 0
local amount = 50
local fakeCamera = Instance.new("Camera")
fakeCamera.Parent = workspace.Camera
for count = 0, amount do
local Viewport = script.Parent.Frames.ViewportFrame:Clone()
Viewport.Parent = script.Parent.Frames
local RunService = game:GetService("RunService")
Viewport.CurrentCamera = fakeCamera
Viewport.ImageTransparency = 0.4
Viewport.ImageColor3 = Color3.new(math.random(0,1), math.random(0,1), math.random(0,1))
Viewport.Size = UDim2.new(increment, 0, increment, 0)
increment += 0.02
for _, c in pairs(workspace:GetChildren()) do
pcall(function()
c:Clone().Parent = Viewport
end)
end
end
while true do
fakeCamera.CFrame = workspace.CurrentCamera.CFrame
task.wait(0.5)
end
I know my code is extremely crude and unoptimized but I’m just trying to get a prototype done as soon as possible.