Dragging Objects on Mobile: Visual Lag Between Finger Movement and Object Position

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:

  1. Increased the update frequency:
    I set update_frequency in game.project to 60 under [display] to ensure smooth updates. However, the issue persists.
  2. Modified the dragging logic:
    I’m using gui.set_position to move the objects to action.x and action.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.
  3. Adjusted input handling:
    I double-checked my on_input logic, ensuring the movement happens during the action_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:

  1. Is there a known way to handle touch inputs in Defold for smoother dragging, especially on mobile?
  2. Are there best practices for optimizing touch input responsiveness?
  3. 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!