1
\$\begingroup\$

I have a scene with two viewports, the "root" viewport and another inside it, like this:

Root
- SomeNode1
- SomeNode2
- RootCamera
- Viewport
  - SomeDeeperNode1
  - ViewportCamera

Now, I have a script attached to a node that belongs to the Viewport node, and it works otherwise, but its _input() method is not called. The script itself works because if I move it out of Viewport (so that it's under Root node) it works fine. Is there something that should be taken into consideration for the _input() method to be invoked when it's located inside another viewport?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

For your Viewport to get input, it must be inside a ViewportContainer. Thus, if you want the inner Viewport to receive input, you must put it inside a new ViewportContainer (it can have no size, or be invisible, input should still work).

The alternative is, of course, to manipulate the Viewport from an script located elsewhere where it can get input.

By the way, if you enable gui_disable_input your Viewport will not get input, nor anything inside of it.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .