How do I adjust the GPU Pixel Snapping project setting at run-time?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gemini

So, for the game I’m working on, given a high degree of precision to the graphics, everything moves and animates better with pixel snapping at 1080p and 4K resolutions, but with all other resolutions they move and animate better without pixel snapping. However, changing the pixel snapping setting at run-time based on the current window/display resolution like this:


…doesn’t work. Going from a default state of false to true or a default state of true to false doesn’t make a difference; changing the setting is not actually adjusting how this works at run-time. So… how do I ACTUALLY adjust this at run-time?

:bust_in_silhouette: Reply From: GoGoGodot

So, I ran into this while trying to figure out how to do it in godot 4(alpha 14). I tested it in 3 and I don’t think the solution is the same, but it might get you or someone else on the right path. This is how you do it in 4:

get_viewport().snap_2d_transforms_to_pixel = bool

So it might be somewhere in the window/viewport settings.