![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Venom357 |
I want to know how to add fps counter in game that still tehere after export.
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Venom357 |
I want to know how to add fps counter in game that still tehere after export.
![]() |
Reply From: | timothybrentwood |
Create a label and attach the following script:
extends Label
func _process(delta: float) -> void:
set_text("FPS " + String(Engine.get_frames_per_second()))
Then put it somewhere in your scene.
String will not convert to String from a Float, as of Godot 4
String(from: String)
String(from: NodePath)
String(from: StringName)
You will need to use the str(float | int)
method.
TheNormandyProject | 2023-02-19 14:18
This works in Godot 4
set_text("FPS %d" % Engine.get_frames_per_second())
terrarum | 2023-04-11 10:08
So what’s the whole fps counter code for 4.2
The comments above say the code for Godot 4, but if you want another answer, you can use string formatting.
extends Label
func _process(delta: float) -> void:
text = "FPS: %s" % [Engine.get_frames_per_second()]