0 votes

I made a simple fps counter the problem is that if I switch scenes the fps counter disappears.

var FPS_Counter = false

func _on_CheckButton2_pressed():
if FPS_Counter == false:
    FPS_Counter = true
else:
    FPS_Counter = false

func _process(delta):
if FPS_Counter == true:
    $FPS.text = str(Engine.get_frames_per_second())
else:
    $FPS.text = str("")

Any Idea on how to transfer the Label to another scene?

Godot version 3.5
in Engine by (12 points)

1 Answer

0 votes

FPS counter sounds like something you want to be on the screen all the time, look into singletons. They allow you to create global scripts and scenes that are always active in the scene tree.
doc link: :https://docs.godotengine.org/en/stable/tutorials/scripting/singletons_autoload.html

(If you didn't already, you will also want to have your label under a canvas layer so that it will always be ontop if you end up using a global scene.)

Hope that helps!

by (829 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.