I’m working on Draggable Camera Script for my game. Following script is the script I’m currently working on. It works in computer but it doesn’t work well in mobile. Can anyone help?
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Camera = workspace:WaitForChild("Camera")
local Mouse = player:GetMouse()
Camera:GetPropertyChangedSignal("CameraType"):Wait()
Camera.CameraType = Enum.CameraType.Scriptable
local Origin = CFrame.lookAt(Vector3.new(0, 100, -25), Vector3.new(0, 0, 0))
local OldMousePos = Vector2.zero
local Speed = 3000
local Moved = Vector2.zero
Mouse.Button1Down:Connect(function()
Dragging = true
OldMousePos = Vector2.new(UIS:GetMouseLocation().X / VS.X, UIS:GetMouseLocation().Y / VS.Y)
print(Dragging)
end)
Mouse.Button1Up:Connect(function()
Dragging = false
print(Dragging)
end)
RunService.RenderStepped:Connect(function(deltaTime)
if Dragging then
Moved += (Vector2.new(UIS:GetMouseLocation().X / VS.X, UIS:GetMouseLocation().Y / VS.Y) - OldMousePos) * Speed * deltaTime
OldMousePos = Vector2.new(UIS:GetMouseLocation().X / VS.X, UIS:GetMouseLocation().Y / VS.Y)
Camera.CFrame = Origin * CFrame.new(-Moved.X, Moved.Y , 0)
end
end)