I’m working on a game in Godot and I’m facing an issue with the positioning of pipes when resizing the window. Any help is greatly appreciated!
Project settings:
Stretch Settings: I’m using canvas_item and keep for the stretch settings.
Problem: When I run the game in a native window, everything works fine. However, when I resize the window (height):
If I make the window smaller, the bars appear in the center of the viewport for y-axis.
If I make the window larger, the bars appear way below the viewport, and the x-axis positioning gets messed up too.
Debugging: I added debug prints and checked the size. The y-coordinate seems fine after resizing, but the pipes still spawn a little lower than the center of the viewport instead of spawning out of the viewport. I even manually calculated the viewport.size debug and the size is indeed true.
The relevant part of my code :
var viewport_size = get_viewport().size
bar_instance.position.y = viewport_size.y + 10
bar_instance.position.x = randf_range(viewport_size.x * 0.25, viewport_size.x * 0.75)
No matter what int I keep here (viewport_size.y + 10), the instance position always gets messed up. viewport_size.y + 10 or viewport_size.y + 1000 gives same problem