![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | mrkaio |
Hello,
I have a problem with input on an Area2D node which is a child of a viewport. (Godot v3.1.1.stable official)
A test setup works fine:
-DemoViewport (Node)
--Area2D (has GDScript and CollisionObject2D:input_event connected with _on_Area2D_input event)
---Sprite
----CollisionShape2D
GDScript of Area2D:
extends Area2D
func _on_Area2D_input_event(viewport, event, shape_idx):
if event is InputEventMouseButton && event.pressed:
print("_on_Area2D_input_event")
Result:
As soon as I click on the Area2D the output in the console is
_on_Area2D_input_event
Now I change the project setup to:
-DemoViewport (Node)
--ViewportContainer
---Viewport
----Area2D (has GDScript and CollisionObject2D:input_event connected with _on_Area2D_input event)
-----Sprite
-----CollisionShape2D
No changes in GDScript or the connection
Result:
The function “_on_Area2D_input_event” will be never called.
If I understand correct, the viewport consume the input events but I could not find any configuration so the input event of the Area2D node is triggered again.
Where is my mistake?