Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Derp Not making camera woozy?

This is in a local script in starterplayerscripts. I was wondering why it doesn't affect the camera like it should.....

local cam = game.Workspace.CurrentCamera

game:GetService("RunService"):BindToRenderStep("Derp",Enum.RenderPriority.Camera.Value,function()
	local t = tick()
	local s = 0.2 + ((1+math.sin(t))/2)*8
	local c = 0.2 + ((1+math.cos(t))/2)*8
	local x,y,z,xx,yx,zx,xy,yy,zy,xz,yz,zz = cam.CFrame:components()
	cam.CFrame = CFrame.new(x,y,z,xx*s,yx*c,zx,xy*s,yy*c,zy,xz*s,yz*c,zz)
end)

1 answer

✓ Accepted answer

Right, got me confused for second as well. The 8 is supposed to be 0.8. Idea is that you want to have s and c in range of 0 to 1.

Also, the render priority has to be last, because it seems that roblox doesn't get to update the camera yet, so it overwrites your changes.

local cam = game.Workspace.CurrentCamera

game:GetService("RunService"):BindToRenderStep("Derp", Enum.RenderPriority.Last.Value, function()
    local t = tick()
    local s = 0.2 + ((1+math.sin(t))/2)*0.8
    local c = 0.2 + ((1+math.cos(t))/2)*0.8
    local x,y,z,xx,yx,zx,xy,yy,zy,xz,yz,zz = cam.CFrame:components()
    cam.CFrame = CFrame.new(x,y,z,xx*s,yx*c,zx,xy*s,yy*c,zy,xz*s,yz*c,zz)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.