Custom InputEvent order (especially for scenes with 2D, 3D and Control nodes simultaneously) #8965
jkvastad
started this conversation in
Engine Core
Replies: 1 comment 3 replies
-
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 5999b85988..f5ca4f00d7 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -867,6 +867,10 @@ void Viewport::_process_picking() {
}
}
+ if (2d_occludes_3d && is_input_handled()) {
+ return;
+ }
+
#ifndef _3D_DISABLED
CollisionObject3D *capture_object = nullptr;
if (physics_object_capture.is_valid()) { However implementing the option to support all cases (2d occludes 3d / 3d occludes 2d / no occlusion in both directions) is more tricky.
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently input is handled via input event in an 8 step process, where control nodes are handled in step 4, unhandled input in step 7 and object picking in step 8.
In games using 2D, 3D and GUI simultaneously this is currently limiting in a few ways:
Now consider which behaviors Godot can support when clicking this stack of three different types of nodes:
GUI Control nodes can consume or pass event forward to object picking, but not the other way around (maybe in some game the 2D foreground should come before the HUD - perhaps you want to play cards directly onto the HUD to change it)
There is no way for 2D nodes to occlude 3D nodes, since they are done with different simultaneous ray casts in step 8. Thus clicking on cards clicks "through" them, inadvertently selecting world objects e.g. zooming in on planets/cities in a Terraformers style game.
Let's say i want to release a card in unhandled_input, e.g. if someone drops a card (left mouse up) on empty space -> return it to hand. But I only know if a position is empty after object picking, which is after unhandled_input. How are we supposed to deselect things?
The closest solution to these i have found is event polling in _physics_process, which handles point 2 and 3, but introduces problems with Control nodes - I have not seen any way to check if my 3D/2D nodes are occluded by Control nodes when using event polling.
I am not sure what the solution should be, but these are problems causing me much headache. Perhaps a possibility to reorder InputEvent, or inject custom events in the event chain?
Beta Was this translation helpful? Give feedback.
All reactions