0 votes

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 inputevent 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??

in Engine by (40 points)
edited by

2 Answers

+2 votes

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

by (18 points)
edited by
0 votes

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.

by (14 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.