Area2D input_event not connecting in Godot 3.

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

I am trying to migrating my old drag and drop script to Godot 3 and found “input_event, mouse_entered and mouse_exited” for Area2D in not connecting.

Except CollisionObject2D events other events are working fine for Area2D.

The Script was working fine in Godot 2.*.

Following is the sample code I used to test.

func _ready():
	var dd = get_node("Area2D").connect("input_event",self,"_on_Area2D_input_event")

func _on_Area2D_input_event( viewport, event, shape_idx ):
:bust_in_silhouette: Reply From: mateusak

It works fine.
This could be caused be thousands of reasons, but it’s not the code.
Make sure the Area2D is set to Pickable.
Make sure your Collision is properly set.
And next time post more info.

Thanks for your suggestion.

hi2din | 2018-02-12 00:17

:bust_in_silhouette: Reply From: hi2din

I fixed this my own by replacing root node from Container to Node2D.

The CollisionObject2D events not working if we place any control object (Container, Panel, TextureRect, etc.) as root node (I don’t know the reason but it was worked well in Godot 2).

Edit 1:

As instructed by literalcitrus
mouse_filter = MOUSE_FILTER_IGNORE
fixed the issue without changing the type of root container.

The Container was eating the events and never reached the Area, look at input events in the documentation to see how that works.

InputEvent — Godot Engine (3.0) documentation in English

eons | 2018-02-14 03:22

Check the mouse_filter property of the root Container node. Changing that around might solve the initial problem. You can check the MouseFilter enum here:

literalcitrus | 2018-02-14 03:25

Yes, you are right… It works fine after I set property

mouse_filter = MOUSE_FILTER_IGNORE for root container.


hi2din | 2018-02-15 01:17

:bust_in_silhouette: Reply From: nastya.sim

I encountered the same problem.
Check “Project Settings → Physics → Common → Enable Object Picking”, must be “enabled”.