KinematicBody2D event not triggered when collide other object

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By nathoenk
     func render_content_inventory():
       	...
       	for slot in slots:
       	    ...
    		if (Inventory.get_data(slot.index)):
    			var kinematic_body = KinematicBody2D.new()
    			kinematic_body.set_name('kinematic_item_slot_'+str(slot.index))
    			kinematic_body.set_global_position(Vector2(20,100))
    			kinematic_body.set_pickable(true)
    			var collision = render_collision_shape(
    				'collision_item_slot_'+str(slot.index),
    				{'x': 0 - style.width_2 * 0.8 / 2, 'y': 0},
    				{'width': style.width_2 * 0.8, 'height': style.height_4 * 0.8}
    			)
    			kinematic_body.add_child(collision)
    			$window_inventory.add_child(kinematic_body)
    		if $window_inventory.get_node('kinematic_item_slot_'+str(slot.index)):
    			$window_inventory.get_node('kinematic_item_slot_0').connect("input_event",self,"on_input_event")

func on_input_event(viewport, event, shape_idx):
	print('hover in')
	if event is InputEventMouseButton:
		if event.button_index == BUTTON_LEFT and event.pressed:
			emit_signal("dragsignal")
		elif event.button_index == BUTTON_LEFT and !event.pressed:
			emit_signal("dragsignal")
	elif event is InputEventScreenTouch:
		if event.pressed and event.get_index() == 0:
			self.position = event.get_position()

its only trigger when I hover outside PopupDialog

Your KinematicBody2D has a collisionobject2d (the blue thing), right? I’m not sure what’s going on exactly, but it needs to collide with another CollisionObject2d for an event to trigger or physics to simulate. And from what I see in the image, there is no 2nd CollisionObject2d to collide with.

TheJokingJack | 2021-04-12 20:25