Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | hide |
Hi,
I have many “Pawn”, “Pawn1”… scene instances in my game, i’d like to be able to select only one at once with a mouse left click. Right click would also be deselecting the one.
But when i left click on one and then another it select the second while letting the first selected.
Right click does unselect all as intended.
func _on_Area2D_mouse_entered():
selectable = true
func _on_Area2D_mouse_exited():
selectable = false
func _input(event):
if event is InputEventMouseButton and event.button_index == 1 and selectable:
emit_signal("unselect")
selected = true
if event is InputEventMouseButton and event.button_index == 2:
emit_signal("unselect")
func _on_Area2D_unselect():
selected = false
EDIT : Actually while trying to explain the problem I found the solution, i had to do this :
if event is InputEventMouseButton and event.button_index == 1:
emit_signal("unselect")
if selectable:
selected = true
But can someone explain to me why would the conditions prevent the signal to be propagated to other instances that (i think) should just execute the received signal in _on_Area2D_unselect() ?