Code instanced button unable to be pressed.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By koolkat

I’m building a simple game to emulate a board game. In it there is a board (TileMap) and then pieces (node Tree Below)

Area2D → (CollisionShape2d, Node2d(move holder), RayCast2D, CenterContainer → TextureButton)

When a button is pressed it instances in all possible moves accounting for collisions as a Move (tree Below)

Area2D → (CollosionShape2D, TextureButton)

This works for most buttons as moves and once the move is clicked it executes the move to move the piece to the place where the move node was globally. My issue is that for some reason One of the capture moves is not able to execute. The other capture move is able to execute, but one doesn’t seem to be able to be clicked.

What I’ve tried:
Moves as CentreContainer → TextureButton
Setting all but TextureButton mouse_filter to pass or ignore

The odd thing is that for one piece the capture move works fine, but that might be because the piece does a single move then allows for a single capture, while the second one it is a move ontop of the other piece that does the capture? Is there anything else I should look at or any other way around that I should be using instead of having TextureButtons?

I’ve put the code in a git repo at:

thanks for any help

:bust_in_silhouette: Reply From: koolkat

What I’ve managed to seem to do with regards to fixing it is to set the mouse_filter property on both the CenterContainer and the TextureButton to Control.MOUSE_FILTER_IGNORE and then set it back to Control.MOUSE_FILTER_STOP when appropriate. I had thought that just disabling the button under the movement button would be sufficient, but I guess not. It MIGHT be possible to keep it as Control.MOUSE_FILTER_PASS, but as it is working now I’m not going to mess with it :stuck_out_tongue: