So, I have a recreation of the roblox studio camera. It’s pretty good, but zooming into a position when scrolling is a problem. It always seems to build up instead of being set.
Normal camera (studio):
Recreation camera:
Does anyone know how to fix this?
Code:
uis.InputChanged:Connect(function(inp, gp)
if inp.UserInputType == Enum.UserInputType.MouseWheel and not gp then
local loc = uis:GetMouseLocation()
local ray = cam:ViewportPointToRay(loc.X, loc.Y)
local direction = (inp.Position.Y/math.abs(inp.Position.Y))
cam.CFrame = CFrame.lookAt(cam.CFrame.Position, ray.Origin + ray.Direction * 1000)
cam.CFrame *= CFrame.new(0,0,-self.mouse_wheel * direction) -- mouse_wheel is 15
end
end)