Why my KinematicBody2D _input_event() does not get called?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Godotmus

I have set KinematicBody2D Pickable to “On” and it has CollisionShape2D (circleshape) also. (KinematicBody2D script snip…)

func _input_event(viewport, event, shape_idx):
print(event) # never gets here..
if event is InputEventMouseButton and event.pressed and event.button_index == BUTTON_LEFT:
	emit_signal("left_click_down", self.get_parent())

elif event is InputEventMouseButton and event.pressed == false and event.button_index == BUTTON_LEFT:
	emit_signal("left_click_up", self.get_parent())

I had “exactly” same way done KinematicBody (3d) and it responsed fine to mouse clicks etc. Also my node structure is similar between working 3d and not working 2d

mouse_entered signal also does not work with KinematicBody2D

I created similarly structured test project for this and in there KinematicBody2D _input_event worked fine… so it must be something in my code

From googling it looks like some other element eat events… I have not much else than background picture and label… (test sample did not have those) I thought events go through topmost object… looks like no??

:bust_in_silhouette: Reply From: Calvin Wong

A bit late, but you just have to check the “Pickable.” box for your KinematicBody2D.
Edit: Nevermind! I misread, this is my code that is working:

if event is InputEventMouseButton and event.is_pressed() and event.button_index == BUTTON_LEFT:

For everyone else, make sure that pickable is pressed! That was what messed me up. For you the second clause should be event.is_pressed() instead of event.pressed

:bust_in_silhouette: Reply From: NuLynx

I also had this problem where it won’t event get to the first line. I think it’s a bug. What helped me was, I had control node as a parent and after changing it to the basic node and back to control node did it.