Godot Version
4
Question
I created an Item scene, which I inherit for Water (and other items)
In Item, I implemented Drag And Drop functionality using the following code:
func _ready():
print("Item Ready")
if(self.get_node("Area2D")):
var area : Area2D = self.get_node("Area2D")
area.connect("input_event", _on_area_2d_input_event)
func _on_area_2d_input_event(_viewport, _event, _shape_idx):
if Input.is_action_just_pressed("click"):
print(self)
selected = true
print("selected")
func _input(event : InputEvent):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and not event.pressed and selected:
selected = false
print(self)
print("dropping " + str(self))
Events.emit_signal("itemDroppedAtLocation", self)
In one of my screens, the drag and drop works.
In the other, it doesn’t.
When I do some print-debugging, I see that the event is connected in the _ready of the placed Item, but clicking the item doesn’t react at all.
All of my “screens” are scenes based on a Node2D.
Items all have an Area2D child node.
If I add a Test “screen” the drag and drop does work.
I can add additional info, but am unsure on what is best given to fix this.
All help (urgently) appreciated