To be honest, the issue I have was already discussed on this reddit post, but he never seemed to have solved his problem. Here's a TL;DR for anyone who doesn't wanna go through:
I have a scene with an Area2D and a CollisionPolygon2D, and I want to detect mouse clicks in that area.
I connected the input event through the editor, and this is the function it's connected to:
func _on_input_event(viewport: Node, event: InputEvent, shape_idx: int):
if Input.is_action_just_pressed('left_click'):
print('clicked!')
of course, left_click is a valid action on the input map.
The problem is that it doesn't detect clicking of any kind. I've tried things like if event is InputEventMouseButton and it doesn't pass, except for under one odd condition.
The only time a mouse event (other than motion and scrolling) is detected properly, is the exact same frame that the mouse enters the Area2D.
Finally the real kicker; my code functions properly without any issues on a brand new project. Btw my original project is just a prototype, so it was also freshly created yesterday.
Something that wasn't mentioned on the reddit post but is something I noticed for my case, is that my .tscn file is "corrupting". Well, at least the editor doesn't want to open it because it thinks it's corrupted, but like I said the exact same file (copied over) works just fine on a brand new project.
I didn't mess with any settings on the original project either, so I don't understand why it's acting this way at all.
The prototype was going to be used in a bigger project that's been in development for months already, so I can't really bank on just creating a new project and transfering files; it'd be way too much work if I was required to do so for the big project as well. I need a proper solution, or at least proper understanding of the problem.