Hi!
I'm trying to make a drag and drop system, and it kinda works. However, when I add a Camera2D, the position of the InputEventMouseMotion Event becomes weird and isn't where the mouse is.
I have two scenes: The first one is the object being dragged, and that scene is contained in another scene (Which has a few other things I've hidden for visibility). The hierarchy of the first scene looks like this. The script attached to the root node is the following (Shortened at some points):
var being_dragged: bool = false
# Used for a "popup"-effect
var expand_by = 1.5
func _input(event):
# Here, the actual movement happens (I'm using global positions)
if being_dragged and event is InputEventMouseMotion:
global_position = event.get_global_position()
if event.is_action_released("drag_piece") and being_dragged:
being_dragged = false
$Texture.set_scale($Texture.get_scale()/expand_by)
# Thats the signal that the Area2D sends
func _on_area_2d_input_event(viewport, event, shape_idx):
if event.is_action_pressed("drag_piece"):
being_dragged = true
$Texture.set_scale($Texture.get_scale()*expand_by)
If I use that scene like it is, it works without any problems, but when I add a stationary Camera2D alongside that scene like this (BasePiece is the scene), the whole thing becomes very buggy, as seen in this gif (The framerate is slow because I don't have a PC capable of properly recording).
The position the InputEventMouseMotion Event reports seems to be relative to the blue rectangle seen in every scene near 0, 0, and the object I'm dragging seems to be restricted to it.
Note: This is a repost from my reddit post, found here: https://www.reddit.com/r/godot/comments/15z46j7/camera2d_messes_up_inputeventmousemotion/?utm_source=share&utm_medium=web2x&context=3