Answers for "how to make a fps counter in godot"

0

how to make a fps counter in godot

extends Label

# Timestamps of frames rendered in the last second
var times := []

# Frames per second
var fps := 0


func _process(_delta: float) -> void:
	var now := OS.get_ticks_msec()

	# Remove frames older than 1 second in the `times` array
	while times.size() > 0 and times[0] <= now - 1000:
		times.pop_front()

	times.append(now)
	fps = times.size()

	# Display FPS in the label
	text = str(fps) + " FPS"
Posted by: Guest on July-23-2021

Code answers related to "how to make a fps counter in godot"

Browse Popular Code Answers by Language