Hi everyone,
I’m currently developing a game in Defold where players can drag objects to specific target positions (like matching pieces to shadows). Everything works fine in the editor and when testing on desktop, but I’m facing a visual bug on mobile devices.
When dragging an object with touch input, the object doesn’t follow the finger smoothly. There’s a noticeable lag between the touch position and the object’s movement, making the interaction feel unresponsive.
Here’s what I’ve already tried to fix the issue:
-
Increased the update frequency:
I setupdate_frequency
ingame.project
to60
under[display]
to ensure smooth updates. However, the issue persists. -
Modified the dragging logic:
I’m usinggui.set_position
to move the objects toaction.x
andaction.y
during touch events. I ensured the object’s position is updated continuously while the user’s finger is moving, but it still feels unresponsive. -
Adjusted input handling:
I double-checked myon_input
logic, ensuring the movement happens during theaction_id == hash("touch")
event. However, the bug still occurs.
function on_input(self, action_id, action)
if action_id == hash("touch") then
if action.pressed then
for _, obj in ipairs(objects) do
if gui.pick_node(obj.node, action.x, action.y) then
dragging = obj
break
end
end
elseif dragging and not action.released then
gui.set_position(dragging.node, vmath.vector3(action.x, action.y, 0))
elseif action.released and dragging then
dragging = nil
end
end
end
The dragging works, but the object lags slightly behind the finger during quick movements on mobile devices.
My questions are:
- Is there a known way to handle touch inputs in Defold for smoother dragging, especially on mobile?
- Are there best practices for optimizing touch input responsiveness?
- Could this issue be related to the rendering or frame synchronization in mobile environments?
I’d really appreciate any advice or insights you might have. Thank you in advance for your help!