SubViewportContainer blocks mouse input

Godot version: 4.3v Stable

Question

Hey all, my first post here. I will start by stating I am mostly a newbie to Godot but as I’ve been learning to make my game, I’ve ran into an annoying issue. My game structure is like this:

image

Mouse inputs do not get passed down the tree to be handled, as I’ve went up the tree debugging everything and found out that while SubViewportContainer DOES receive inputs, it does not send them to SubViewport and, consequently, I can’t click the buttons you see in the control node inside the player character.

I’ve attempted a few solutions before coming here. The first was setting the mouse filter to pass and stop at the buttons, but that did not work. Then, I attempt to use this script to push inputs down the chain forcefully:

extends SubViewportContainer

func _ready() -> void:
	set_process_input(true) 

func _input(event: InputEvent) -> void:
	for child in get_children():
		if child is SubViewport:
			child.push_input(event)
	

However that did not work, as it duplicates inputs (During my dialogue script for example, it’ll skip dialogues) and it also does not capture “Hover” events like I hoped it would.

I am not sure how to fix this, I’ve looked through the SubViewportContainer documentation and the only thing I’ve found that could help is “Propagate_Input_event” but as it is an experimental feature, I’m not sure how or if I should implement it.

Hey @StarlightChaser01 - In the event that you haven’t solved this, or someone else like me has the same issue and comes across this post, here is how I solved it:

  1. I have a HUD control node that collects & organizes HUD components. It exists as a child of a CanvasLayer node that is a sibling to my SubViewportContainer. I had to update the Control->Mouse->Filter property to Ignore so it wouldn’t gobble up inputs.
  2. On my SubViewport, the Physics->Object Picking property needed to be enabled.

Once those two changes were made, I was able to have an Area2d node within my SubViewport handle mouse-entered/exited events. Hope this helps!

1 Like

Not the original poster but—Wow! You are an absolute life-saver!

I was well acquainted with the mouse filters, but enabling Object Picking was what did the trick for me. I would not have found that in a life time.

Thanks!

1 Like