admin管理员组文章数量:1023764
I need 2 windows in my my game, one window shows the normal game and the second window is a game master view that will show the same content from the same perspective but with extra information such as hit boxes any maybe some text with stats. The normal window will be dragged on to a second monitor and maximized while the game master window will remain on the primary monitor, remain windowed, and moved around and resized. The game itself is currently 2D but I'll soon be adding 3D objects.
I followed this tutorial, #contents-of-this-repository, and was able to get my game master window working but it won't scale the contents. Even as my normal window scales it's content the content in the game master window appears to stay scaled to the original size of the normal window and I only see the upper left corner of the content.
I'm also not sure if this will allow me to selectively render elements on the normal window and the game master window. My original implementation of this was a PyQt application that simply drew the game twice, once in normal mode and once in game master mode.
I need 2 windows in my my game, one window shows the normal game and the second window is a game master view that will show the same content from the same perspective but with extra information such as hit boxes any maybe some text with stats. The normal window will be dragged on to a second monitor and maximized while the game master window will remain on the primary monitor, remain windowed, and moved around and resized. The game itself is currently 2D but I'll soon be adding 3D objects.
I followed this tutorial, https://github/geegaz/Multiple-Windows-tutorial?tab=readme-ov-file#contents-of-this-repository, and was able to get my game master window working but it won't scale the contents. Even as my normal window scales it's content the content in the game master window appears to stay scaled to the original size of the normal window and I only see the upper left corner of the content.
I'm also not sure if this will allow me to selectively render elements on the normal window and the game master window. My original implementation of this was a PyQt application that simply drew the game twice, once in normal mode and once in game master mode.
Share Improve this question asked Nov 18, 2024 at 19:17 HahaHortnessHahaHortness 1,6281 gold badge16 silver badges16 bronze badges1 Answer
Reset to default 2Eventually I realized that what I'm trying to do is more similar to a Split screen game which this video explains how to do, https://www.youtube/watch?v=tkBgYD0R8R4. By replacing SubViewports with Windows I was able to render into separate windows. On the game master window I set content_scale_mode to Canvas Items and content_scale_aspect to Keep and then in gdscript I wrote.
func resize() -> void:
%GameMasterView.content_scale_size = Vector2i(get_window().size)
get_viewport().size = get_window().size
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
get_tree().get_root().size_changed.connect(resize)
resize()
At this point the view was being properly reproduced in the second window.
I struggled for a long time with showing extra details on the game master view. I tried to set the following up.
- Root (Node3D)
- SubViewportContainer
- SubViewport (normal view)
- Window (game master view)
- *Rest of the scene
- SubViewportContainer
and then I set the SubViewport Canvas Cull Mask to 1 and the WindowCanvas Cull Mask to 1 and 2. All my game master only items had their visibility layer set to 2. But for some reason it seemed that the Window couldn't render anything that wasn't rendered in the SubViewport. Eventually I Reduced it to just.
- Root (Node3D)
- Window (game master view)
- *Rest of the scene
and in a gdscript I callled get_window().canvas_cull_mask = 1
to set the cull mask on the default viewport and this worked.
I need 2 windows in my my game, one window shows the normal game and the second window is a game master view that will show the same content from the same perspective but with extra information such as hit boxes any maybe some text with stats. The normal window will be dragged on to a second monitor and maximized while the game master window will remain on the primary monitor, remain windowed, and moved around and resized. The game itself is currently 2D but I'll soon be adding 3D objects.
I followed this tutorial, #contents-of-this-repository, and was able to get my game master window working but it won't scale the contents. Even as my normal window scales it's content the content in the game master window appears to stay scaled to the original size of the normal window and I only see the upper left corner of the content.
I'm also not sure if this will allow me to selectively render elements on the normal window and the game master window. My original implementation of this was a PyQt application that simply drew the game twice, once in normal mode and once in game master mode.
I need 2 windows in my my game, one window shows the normal game and the second window is a game master view that will show the same content from the same perspective but with extra information such as hit boxes any maybe some text with stats. The normal window will be dragged on to a second monitor and maximized while the game master window will remain on the primary monitor, remain windowed, and moved around and resized. The game itself is currently 2D but I'll soon be adding 3D objects.
I followed this tutorial, https://github/geegaz/Multiple-Windows-tutorial?tab=readme-ov-file#contents-of-this-repository, and was able to get my game master window working but it won't scale the contents. Even as my normal window scales it's content the content in the game master window appears to stay scaled to the original size of the normal window and I only see the upper left corner of the content.
I'm also not sure if this will allow me to selectively render elements on the normal window and the game master window. My original implementation of this was a PyQt application that simply drew the game twice, once in normal mode and once in game master mode.
Share Improve this question asked Nov 18, 2024 at 19:17 HahaHortnessHahaHortness 1,6281 gold badge16 silver badges16 bronze badges1 Answer
Reset to default 2Eventually I realized that what I'm trying to do is more similar to a Split screen game which this video explains how to do, https://www.youtube/watch?v=tkBgYD0R8R4. By replacing SubViewports with Windows I was able to render into separate windows. On the game master window I set content_scale_mode to Canvas Items and content_scale_aspect to Keep and then in gdscript I wrote.
func resize() -> void:
%GameMasterView.content_scale_size = Vector2i(get_window().size)
get_viewport().size = get_window().size
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
get_tree().get_root().size_changed.connect(resize)
resize()
At this point the view was being properly reproduced in the second window.
I struggled for a long time with showing extra details on the game master view. I tried to set the following up.
- Root (Node3D)
- SubViewportContainer
- SubViewport (normal view)
- Window (game master view)
- *Rest of the scene
- SubViewportContainer
and then I set the SubViewport Canvas Cull Mask to 1 and the WindowCanvas Cull Mask to 1 and 2. All my game master only items had their visibility layer set to 2. But for some reason it seemed that the Window couldn't render anything that wasn't rendered in the SubViewport. Eventually I Reduced it to just.
- Root (Node3D)
- Window (game master view)
- *Rest of the scene
and in a gdscript I callled get_window().canvas_cull_mask = 1
to set the cull mask on the default viewport and this worked.
本文标签: Godot Game With 2 Windows for Player and Game MasterStack Overflow
版权声明:本文标题:Godot Game With 2 Windows for Player and Game Master - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745599357a2158364.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论