I want to make a draggable isometric game like clash of clans
like this: https://youtu.be/DaZWdT003AI?si=aRN9_0CrPRn556VV&t=50
here my attempt to make it by using a script from similar topic:
local run = game:GetService'RunService'
local uis = game:GetService'UserInputService'
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local cam = workspace.Camera
cam.CameraType = Enum.CameraType.Scriptable
local speed = .2 -- Speed when dragging
local lockMouse = true -- locks mouse when dragging
local origin = CFrame.lookAt(Vector3.new(0,10,0), Vector3.new()) -- Where the camera will start
local moved = Vector2.zero -- How much the camera has moved
local dragging = false
local oldMousePos = Vector2.zero
mouse.Button1Down:Connect(function()
dragging = true
oldMousePos = uis:GetMouseLocation()
end)
mouse.Button1Up:Connect(function()
dragging = false
uis.MouseBehavior = Enum.MouseBehavior.Default
moved = Vector2.zero -- Reset the moved value
end)
run.RenderStepped:Connect(function(dt)
if dragging then
if lockMouse then
uis.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
moved += uis:GetMouseDelta()*speed*dt
else
local currentMousePos = uis:GetMouseLocation()
if currentMousePos ~= oldMousePos then -- Check if the mouse has moved
moved += (currentMousePos - oldMousePos)*speed*dt
oldMousePos = currentMousePos
end
end
end
local isoView = CFrame.new(cam.CFrame.p, cam.CFrame.p + Vector3.new(1, -1, -1))
cam.CFrame = isoView * CFrame.new(-moved.X*speed, 0, moved.Y*speed)
end)
The X axis looks fine but the problem is the Z axis
It moves forward and backward in the direction where camera looking
not in the same Z Axis position it is in
if u understand
just check the example vid link on top to seee what i mean