#Howdy! I need help with multiplayer focus!
19 messages · Page 1 of 1 (latest)
if you use multiple viewports yes, each viewport can have separate focus, though you will need to write code to send input of each player directly to their specific viewport to make things like dpad and A button work
SubViewportContainer can display a viewport and will forward mouse input automatically if you want, you'll still need to handle controller input for each viewport yourself though since with the default input, only one container is in focus
and this is the method you can use to send an input to a specific viewport
https://docs.godotengine.org/en/stable/classes/class_viewport.html#class-viewport-method-push-input
example: run a script in a node in the main viewport (not inside any subviewport) with an _input() function that checks what controller the input is from, and based on that, sends the event to a specific player's viewport calling push_input on it
do viewports have a significant impact on performance? i was really hoping to find some sort of like focus layer functionality or something but it seems like this is the only way to go with this
also i will for sure check out the docs that you linked here
they can have some impact yes, each one will be rendering the game from a different perspective
but that's a natural consequence of split screen gameplay
any kind of split screen needs to use sub-viewports to draw each player's screen from a different perspective
i imagine the best practice with using multiple viewports is to try and limit what the additional ones are showing
in my use case specifically its just UI that needs to be controlled by multiple sources on the same screen
hmm on the same screen (without split screen), I'm not sure if you can do it using the built-in focus system of the engine UI
if you really need that, I think you may need to write your own focus system
all the functions that deal with built in focus only seem to allow setting one thing in focus, or grabbing one focused element, not multiple
interesting ok, i was fearing that it just wouldn't be possible with the built in focus system. it's been super simple and great to use for just single player so i was hoping that maybe itd be as nice for multiplayer
but if it isnt so well! i suppose ill just have to figure something else out, thanks for the information.
i think doing my own hacky semi focus system wont be too difficult, wont be nearly as nice to use as the built in one though lol
at least with a custom system you can also make custom visuals to make things clearer
like when multiple players select the same button, your system can draw an icon or letter or number or something above the button for each player, each icon next to one other
instead of a single border that would overlap the other player selection visually
right yeah thats something i was hoping the base system would feature, but its seeming like the built in UI stuff is pretty lackluster
lots of edgecase stuff like that would make it really hard to use for multiplayer