0 votes

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():

func _input(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:

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.

Godot version 3.4.4
in Engine by (15 points)

1 Answer

0 votes
Best answer

mouse_filter property of every single overlapping control node needs to be "pass" instead of "stop"

by (7,301 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.