Skip to content

Instantly share code, notes, and snippets.

@Shilo
Created November 7, 2024 07:25
Show Gist options
  • Save Shilo/30f0bb56f5ec6d7fd6705d06be5a7cd9 to your computer and use it in GitHub Desktop.
Save Shilo/30f0bb56f5ec6d7fd6705d06be5a7cd9 to your computer and use it in GitHub Desktop.
FPS counter in Godot 4.
extends Label
func _process(_delta: float) -> void:
text = format_number(Engine.get_frames_per_second()) + " FPS"
func format_number(number: Variant, thousand_separator: String = ",") -> String:
var number_str: String = str(number)
var start_index: int = number_str.find(".")
if start_index == -1:
start_index = number_str.length()
for i in range(start_index - 3, 0, -3):
number_str = number_str.insert(i, thousand_separator)
return number_str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment