The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I have the following code, but it isn't working like I would expect.

func _on_Tile_mouse_enter():
    if Input.is_mouse_button_pressed(BUTTON_LEFT):
        print("Left mouse dragged over Tile: ", gridPosition)
    elif Input.is_mouse_button_pressed(BUTTON_RIGHT):
        print("Right mouse dragged over Tile: ", gridPosition)

This is on a Control node with a sprite child node. I would like the tile to do some action if I drag a clicked mouse over the control node, but the above code is not working. If I put a print command outside of the checks for mouse buttons being pressed, that fires every time the mouse enters the tiles, but these ones inside don't fire, usually. If I attempt to click and drag many times in a row, occasionally one of my attempts will work, and every tile I mouse over will fire the message. I can't figure out why it works sometimes but not others.

I have different code that fires on an actual mouse click on the tile, and that works everytime. It's just this code that isn't working.

Is there a different way I should be doing this?

in Engine by (24 points)

is your problem that "these ones inside don't fire"?
then see this answer.

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.