ViewportContainer and Viewport seeming consuming my mouse events, solution?

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

Hi, I’m trying to detect when the user clicks on a node. Works fine by its own, but my game is located in a ViewportContainer → Viewport and this seems to consume the mouse events… Ex; in a NPC node; uses _input_event(...), ex:

func _input_event(viewport, event, shape_idx):
	print('NPC: _input_event(event)');

This works if the NPC node is ran as a scene or in the main ‘world’ scene. But if it is run inside a ViewportContainer containing a Viewport, then it does not work…

Any idea what could be the issue? I think that the ViewportContainer as a ‘Control’ consumes the mouse event, but I can’t find how to change this behavior…


:bust_in_silhouette: Reply From: hilfazer

ViewportContainer has a Mouse->Filter property. Change it to Ignore or Pass.

Tried it and it didn’t make any difference… :\

nwgdusr999 | 2019-07-30 15:56

Do you have other Controls that could be handling mouse events? ‘Filter’ is a property of Control class.

hilfazer | 2019-07-30 16:21

Sorry for delay, did some test with a simple project and as soon as a clickable node with the input_event is within a ViewportContainer and a ViewPort, the event does not work. I tried with different mouse filter values but it did not change anything… Just seems bugged. :frowning:

Btw object pickable needs to be on for the clickable node, and Viewport has a setting; Physics Object Picking which can be set to on/off, but it does not seem to make any difference. I’ve played with pretty much all GUI VP and VPC params that seemed relevant that I could find, nothing works.

I found this earlier, seems related… Anyway, it’s like the above events doesn’t go through viewports. Regular inputs do, but not the _input_event
When set as "render target", viewport blocks input for children nodes · Issue #8419 · godotengine/godot · GitHub

nwgdusr999 | 2019-07-31 12:00

:bust_in_silhouette: Reply From: wyi13

I’ve also meet such problem. Seems except _input_event, other input(_input, _gui_input, _unhandled_input) works well. I’ve also test it in godot4, and this problem doesn’t exist.

It looks like I have to avoid using _input_event in such case with godot3.

:bust_in_silhouette: Reply From: bath_idea

You have to enable Viewport property Physics->Object Picking to allow any click/touch event to pass through object inside viewport. Also change Mouse Filter to pass or ignore.