My problem is this: I am trying to detect a click on a 2D object. Basically, make a unit selected with a click.
Now. I am pretty sure this problem had already arisen a zillion times before. And I have even seen some answers concerning Godot 3. But I can't find anything related close enough. If you know the answer just give me a link pls
I followed the best advice I could find (which was about godot 3.5) and did this:
I created Area2D with CollisionShape2D
I attached a script to Area2D and added this code into _input() function (which seemingly replaced _input_event).
func _input(event: InputEvent) -> void:
if Input.is_action_just_released("mouseLeft"):
doSomething()
But doSomething() always happens, wherever I click. And I do not understand how to limit InputEvent to the boundaries of CollisionShape2D. It seems I don't understand how exactly this input works.
Could you tell me please what I am doing wrong? Or direct me where I could read about it. I can't understand it from Godot help. Thank you.