V-Sync Help I'm New

Godot Version

Godot 4

Question

I am new to the forums and I need some help with making a setting for v-sync. Here is the code I am using:

extends CheckButton

func _on_v_sync_toggled(toggled_on: bool):
   DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
1 Like

It appears you’re setting it to enabled regardless of the value of the parameter toggled_on. Try this.


DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED if toggled_on else DisplayServer.VSYNC_DISABLED)
4 Likes

I’m sorry but it is still not working. (BTW I follow you on Youtube) Here is the current code:

extends CheckButton

func _on_v_sync_toggled(toggled_on: bool):
	DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED if toggled_on else DisplayServer.VSYNC_DISABLED)

Update: Hello? Can anyone help?

Can you explain how it’s not working? What do you expect to happen vs what really happens?

1 Like

So basically, when you turn on the setting, it enables V-Sync in my game. But then nothing happens.

And what exactly do you expect to happen? If you measure FPS, VSync will limit it to the display refresh rate.

1 Like

Yeah that’s what I need for my game for people with a 60 hz monitor or something to stop screen tearing

In that case, keep VSync on and don’t turn it off. Having FPS synced with the display frequency is the best way to avoid screen tearing.

Ok thanks its just I’m only 13 and I’m new to godot