I am attempting to make a dragging system with my own custom handles that players can grab and drag around and that will only move the object in set increments in a single axis. I have it working sort of but as I move the object farther from its origin the mouse gets farther and farther away from the handle. Here is a video of my issue
Id like the handles to stay with the mouse but I can’t seem to figure out how to achieve this, here is my code. Btw the mouse has its target filter set to the handles and the object it’s moving. If that matters.
mouse.Move:Connect(function()
local dragPos = mouse.Hit.p
local difference = selectedHandle.CFrame:PointToObjectSpace(dragPos)
local z = math.abs(difference.Z/movementIncrement) + 0.5
local dist = math.floor(z) * movementIncrement * math.sign(difference.Z)
if math.abs(dist) > 0 then
selectedVertice.CFrame = selectedVertice.CFrame *CFrame.new(movementIncrement * math.sign(dist), 0, 0)
end
end)