This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

In this part of the script, I want to kill the node after the user drags a picture left or right (will become swiping a card on mobile) and emit a signal that tells another parent node what direction was the drag towards.
After the queue free, the same node is re-instanced with updated properties (following card appears).
This works most of the times, but sometimes if the "swiping" is too fast, the current node stays while the new one is reinstanced.
I suppose because queue_free waits for the node to be idle, and if the user keeps clicking it doesn't get idle fast enough to be terminated. Any thoughts how to fix it?

Here is the code:

func _input(event):
    # Detect mouse motion when clicked
    if event is InputEventMouseMotion and event.button_mask&1 :
        var rel_x = event.relative.x
        # if card in the center, add drag card along with mouse motion
        if $BGContainer/BGImage.position.x > (center_position.x-card_slide_from_side) and $BGContainer/BGImage.position.x < (center_position.x+card_slide_from_side):
            $BGContainer/BGImage.position.x += rel_x
        elif $BGContainer/BGImage.position.x >= (center_position.x+card_slide_from_side):
            emit_signal("_swiped", "right")
        elif $BGContainer/BGImage.position.x <= (center_position.x-card_slide_from_side):
            emit_signal("_swiped", "left")

The only problem in the debugger is the error:

0:00:06:0695 - Signal '_swiped' is already connected to given method '_print_swipe' in that object.
Description: Signal '_swiped' is already connected to given method '_print_swipe' in that object.
Time: 0:00:06:0695
C Error: Condition ' s->slot_map.has(target) ' is true. returned: ERR_INVALID_PARAMETER
C Source: core/object.cpp:1413
C Function: connect

It happens thousands of time but usually things work fine.
Should I dynamically create a different signal each time?
A bit lost here.

in Engine by (21 points)
edited by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.