"And" is not working?

godotusergodotuser Posts: 4Member

Hi, do anybody knows, what is wrong?

This is my code:

func _input(event):
if event is InputEventScreenTouch and $Button.pressed != true:

This is to do that if the screen detects a touch (other than buttons) and no button is pressed at the same time, "a" is printed. The problem is that instead of not printing at all if the condition is not met, it prints either once (if I touch the button) or twice (if I don't touch the button). Which is just weird...

Anybody knows, what to do with? Thank you.


  • cyberealitycybereality Posts: 1,431Moderator

    Hi and welcome. Your post was stuck in a moderation queue, but I have approved it. Please confirm your account with the email we sent you so you can post freely in the future. Thanks.

  • cyberealitycybereality Posts: 1,431Moderator

    So, the screen touch event fires for both press and release. So you have to check for that.

    Try it with this code, I think it will work better for what you want.

    func _input(event):
        if event is InputEventScreenTouch and event.pressed:
            if $Button.pressed:
                print("+ + Pressed Button + +")
                print("- - Touched Screen - -")
  • godotusergodotuser Posts: 4Member

    Wow, thank you B)

  • cyberealitycybereality Posts: 1,431Moderator

    Yeah, no problem.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file