centering camera upon resize when used with viewport

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By salth2ofish
:warning: Old Version Published before Godot 3 was released.

I have modeled the split screen platform demo to support split screen for my game.
I have a scene that allows a player to fly around as a spaceship. When I make use of that scene with the split screen viewports everything mostly works, however with one issue i’m not able to figure out: When the window resizes, the camera center stays the same and doesn’t adjust to the new window size.

Can someone please provide me some guidance on how to recenter the camera to the new windows/viewport size?

Thank you.

:bust_in_silhouette: Reply From: avencherus

You can always monitor the root viewport using it’s resize signal. Then calculate what you need from that. It depends though a lot on how you have your project setup, the implementation is up to you.

A simple example:

func _enter_tree():
	get_tree().get_root().connect("size_changed", self, "resized")
	
func resized():
	print(OS.get_window_size())
	# Do resizing calculations here using new size information.