I am experiencing a frustrating situation with the 3D FPS game I am working on. The goal is to be able to have side-by-side local co-op with both a keyboard & mouse and a controller where they control separate players. I have already been able to accomplish side-by-side co-op like that with two controllers. And specifically, I am trying to capture the mouse's movement for the KBM player so I can rotate his camera accordingly.
Here is what the tree looks like for the Viewports:
-- Control
------ HboxContainer
---------- ViewportContainer
-------------- Viewport
---------- ViewportContainer2
-------------- Viewport
The nodes are all expanded and stretched properly. I have tried all I can think of with the mouse filtering on the Control, HboxContainer, and ViewportContainer nodes. I've also tried setting "Handle Input Locally" to true for both Viewports. And then I tried attaching a script to both ViewportContainers that looks like this:
extends Control
func _ready():
set_process_unhandled_input(true)
func _input(event):
print(event)
if event is InputEventMouse:
print('#############\n', self.name, ' mouse event')
The purpose of this was to see if I could catch mouse events in the ViewportContainers and then pass the event down to the Viewport where the keybaord & mouse player lives. However, the only output I got was a bunch of this:
[InputEventMouseMotion:xxx]
#############
ViewportContainer2 mouse event
And this is where I noticed the weird and frustrating behavior. ONLY the second ViewportContainer is receiving mouse events. And further proving that behavior, I confirmed that the device combination works perfectly when the controller player is using the left (first) Viewport and the KBM player is using the right (second) Viewport.
So what I really need help with is figuring out if there is a way that I can receive mouse input in the first Viewport with the configuration I have. If not, I am open to trying different tree configurations. I just need to be able to have side-by-side Viewports that evenly split the screen.