Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubViewport, InputEvent Pressed and Area3D #79128

Closed
kevinloustau opened this issue Jul 6, 2023 · 3 comments
Closed

SubViewport, InputEvent Pressed and Area3D #79128

kevinloustau opened this issue Jul 6, 2023 · 3 comments

Comments

@kevinloustau
Copy link

Godot version

v4.1.stable.official [9704596]

System information

Windows 11

Issue description

Hi,

After updating my project from godot 4.0.3 to 4.1, I noticed the SubViewport blocks the Input Events event pressed on my Area3D.

I made a small Godot project to test the issue with:

  • two cubes rotating when we interact with their Area3D with the signal input_event.
  • one is in front of the camera
  • the other is from the SubViewport,

if the SubViewport is visible, only the content in the viewport receives the event pressed.
Important to note the mouse_entered signal works well.

I made a video to demonstrate the issue (the godot project is avalaible below):
https://drive.google.com/file/d/1gBgL_zsX0A8Y4mFQ0AwpIv0NDygISj_k/view?usp=sharing

Steps to reproduce

  • Create a 3D scene, insert a mesh with an Area3D,
  • Create a SubViewport and place another mesh using Area3D
  • For the two Area3D, connect the signal input_event to a script, and get feedback on the InputEventMouseButton and event.pressed

Area3D code:

func _on_input_event(camera, event, position, normal, shape_idx):
	if event is InputEventMouseButton:
		if event.pressed:
			self.rotate(Vector3.UP,deg_to_rad(45));

func _on_mouse_entered():
	print("Mouse enter on: ", self.name)

Minimal reproduction project

SubViewportAndMouseArea.zip

@Sauermann
Copy link
Contributor

Sauermann commented Jul 7, 2023

I noticed the SubViewport blocks the Input Events event pressed

It would be more precise, that the SubViewportContainer blocks the Input Events. Control-Nodes always accept Mouse clicks, when their mouse-filter is set to PASS. So it is expected, that SubViewportContainer as a Control-Node does the same. This was a problem in the previous version, which lead to inconsistencies and got fixed in #57894.

What you want to achieve is no longer possible with SubViewportContainer but you can use Area2D instead.
Here is a demo-project to showcase one possible way, how this can be done: SubViewportAndMouseAreaWithChanges.zip

@kevinloustau
Copy link
Author

Thank you @Sauermann for the explanations, I implemented what you showcase in the demo-project, and it is working perfectly!

@Sauermann
Copy link
Contributor

I am glad to hear that. Closing this issue accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants