0 votes

How can I call a signal within a signal?

I want to implement:
-if a touchscreenbutton has been after pressed.
only after that
-if an Area2D area is entered (through a collisionshape2d), body entered signal is generated.

Thanks in advance.

in Engine by (100 points)

1 Answer

+2 votes

Use a boolean to keep track of which conditions have been fulfilled:

var button_pressed = false

func _on_TouchScreenButton_pressed() -> void:
    var button_pressed = true

func _on_Area2D_body_entered(body) -> void:
    if button_pressed:
        # ...    enter code here
by (10,483 points)

Thank you very much. This works.

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 webmaster@godotengine.org with your username.