Advertisement
TheDev321

Untitled

Jul 28th, 2021
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1.         table.insert(cameraEvents, conUp)
  2.         table.insert(cameraEvents, conDown)
  3.         table.insert(cameraEvents, conChange)          
  4.            
  5.         local start = os.clock()
  6.         local update = function()
  7.                 if inBuild then
  8.                     local delta = os.clock() - start
  9.  
  10.                     if rotateFlat ~= 0 then
  11.                         rotation = rotation + delta * flatRotSpeed * rotateFlat
  12.                     end
  13.  
  14.                     if zoomFlat ~= 0 then
  15.                         setZoom(zoom - delta * flatZoomSpeed * zoomFlat)
  16.                     end
  17.  
  18.                     local x, z = camPos.x, camPos.z
  19.                     local curMoveDelta = movementDelta
  20.                     local viewportSize = camera.ViewportSize
  21.  
  22.                     if mousePos.X <= mouseZoneOffset then
  23.                         curMoveDelta = Vector2.new((mouseZoneOffset - mousePos.X) / mouseZoneOffset, curMoveDelta.Y)
  24.                     else
  25.                         if viewportSize.X - mouseZoneOffset <= mousePos.X then
  26.                             curMoveDelta = Vector2.new(-(mousePos.X - (viewportSize.X - mouseZoneOffset)) / mouseZoneOffset, curMoveDelta.Y)
  27.                         end
  28.                     end
  29.  
  30.                     if mousePos.Y <= mouseZoneOffset - mouseHeightOffset then
  31.                         curMoveDelta = Vector2.new(curMoveDelta.X, (mouseZoneOffset - mouseHeightOffset - mousePos.Y) / mouseZoneOffset)
  32.                     else
  33.                         if viewportSize.Y - mouseZoneOffset - mouseHeightOffset <= mousePos.Y then
  34.                             curMoveDelta = Vector2.new(curMoveDelta.X, -(mousePos.Y - (viewportSize.Y - mouseZoneOffset - mouseHeightOffset)) / mouseZoneOffset)
  35.                         end
  36.                     end
  37.                     x = x + clamp(curMoveDelta.X, -1, 1) * delta * moveSpeed * math.sin(rotation + math.pi / 2)
  38.                     z = z + clamp(curMoveDelta.X, -1, 1) * delta * moveSpeed * math.cos(rotation + math.pi / 2)
  39.                     x = x + clamp(curMoveDelta.Y, -1, 1) * delta * moveSpeed * math.sin(rotation)
  40.                     z = z + clamp(curMoveDelta.Y, -1, 1) * delta * moveSpeed * math.cos(rotation)
  41.                     warn(moveSpeed)
  42.                     camPos = Vector3.new(clamp(x, -75, 75), camPos.y, clamp(z, -75, 75))
  43.                     camera.CoordinateFrame = module:GetBuildPos(plot)
  44.                     start = os.clock()
  45.                 end
  46.             end
  47.             do
  48.                 runService:BindToRenderStep("CameraMovement", Enum.RenderPriority.Camera.Value, update)
  49.             end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement