Hello all,
I'm trying to make simple 3D game, where you need to drag-and-drop objects to assemble things mechanically.
What I've already accomplished is that you can grab an object, drag it to "Area" node (where it registers a mouse_enter event) and snaps it on mouse button release.
When you want to detach the object, you click on the area, and then the last object snapped becomes animated and follows the mouse.
The problem: When I click on the area and hold the mouse button to drag, other Areas do not receive any event. The strange thing is - if I move the mouse out of the whole window and get it back to Area - it registers.
Any ideas appreciated!
Heres the code detecting events, "unit" is the box where I need to drag and snap objects to:
extends Spatial
signal unitSelected
signal unitDeselected
signal unitMouseEntered
signal unitMouseExited
var itemName
func _ready():
var _err = self.connect("mouse_entered", self, "_on_mouse_entered")
_err = self.connect("mouse_exited", self, "_on_mouse_exited")
_err = self.connect("input_event", self, "_on_input_event")
func _on_input_event(_camera, event, _position, _normal, _shape_idx):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT:
if event.pressed == true:
emit_signal("unitSelected", int(self.name.replace("Unit", ""))) #inject unit number as an argument
else:
emit_signal("unitDeselected", int(self.name.replace("Unit", "")))
func _on_mouse_entered():
$SelectBox.show()
emit_signal("unitMouseEntered", int(self.name.replace("Unit", "")))
func _on_mouse_exited():
$SelectBox.hide()
emit_signal("unitMouseExited", int(self.name.replace("Unit", "")))
Edit: uploaded behavior (yellowish cube is shown with $SelectBox.show()):
https://giphy.com/gifs/Qfs7ow7aTaOOvg82FS