[4.7/Linux/Wayland] - We tried movie maker mode in IDE, but the game framerate set in GDScript is not enforced? Game is running too fast when recorded?

Godot Version

v4.7.stable.official [5b4e0cb0f] - Linux x86_64

Question

Hi,

We tried movie maker mode in IDE, but the game framerate set in GDScript is not enforced?
Video does have audio and video, but the game is running significantly faster than it should?
Any ideas? Video is below:

SS

There’s a project setting “application/run/max_fps” and in code setting Engine.max_fps will enforce a framerate cap.

How are you testing your current framerate cap? Can you share any relevant code?

Hi,

Thank you for helping!
The set Frames Per Second GDScript code is below:

#----------------------------------------------------------------------------------------
func SetFramesPerSecond(fpsValue):

print(fpsValue)

Engine.max_fps = fpsValue
Engine.physics_ticks_per_second = fpsValue

pass

#----------------------------------------------------------------------------------------

Hope someone know how to fix the above, thanks!

SS

Doesn’t really tell much other than you do use Engine.max_fps, where are you calling this function? With what values? What does the print tell you? Again, how are you testing this, what did you expect to happen and what really happened?

Hi,

Play the above video full screen…
On the bottom-left of the game display is the Frames Per Second display.
The Frames Per Second display has two numbers: first is the current FPS and the second is set FPS.
Notice that the current FPS is much higher than the second set FPS.

Game is in Alpha stage currently and we will not upload to GitHub until Beta 1 (feature frozen).
Please see below screenshot of the setting of FPS in code:

SS

How are you calculating this first number? Can you share the label’s script?

Oh sorry, code to calculate FPS is below:

#----------------------------------------------------------------------------------------
func ProcessScreenToDisplay():

ScreenToDisplay = NewHighScoreScreen

if ScreenToDisplay == HTML5Screen:
	DisplayHTML5Screen()
elif ScreenToDisplay == GodotScreen:
	DisplayGodotScreen()
elif ScreenToDisplay == FASScreen:
	DisplayFASScreen()
elif ScreenToDisplay == TitleScreen:
	DisplayTitleScreen()
elif ScreenToDisplay == InputScreen:
	DisplayInputScreen()
elif ScreenToDisplay == OptionsScreen:
	DisplayOptionsScreen()
elif ScreenToDisplay == HowToPlayScreen:
	DisplayHowToPlayScreen()
elif ScreenToDisplay == HighScoresScreen:
	DisplayHighScoresScreen()
elif ScreenToDisplay == AboutScreen:
	DisplayAboutScreen()
elif ScreenToDisplay == MusicTestScreen:
	DisplayMusicTestScreen()
elif ScreenToDisplay == PlayingGameScreen:
	DisplayPlayingGameScreen()
elif ScreenToDisplay == CutSceneScreen:
	DisplayCutSceneScreen()
elif ScreenToDisplay == NewHighScoreScreen:
	DisplayNewHighScoreScreen()
elif ScreenToDisplay == WonGameScreen:
	DisplayWonGameScreen()
elif ScreenToDisplay == NoCPUScreen:
	DisplayNoCPUScreen()
elif ScreenToDisplay == NewGameScreen:
	DisplayNewGameScreen()

if (ScreenToDisplay != PlayingGameScreen):
	InterfaceCore.DrawAllButtons()
	InterfaceCore.DrawAllArrowSets()

InterfaceCore.DrawAllIcons()

ApplyScreenFadeTransition()

if (LogicCore.SecretCodeCombined == 2777 || LogicCore.SecretCodeCombined == 8888 || LogicCore.SecretCodeCombined == 8889):
	VisualsCore.FramesPerSecondText.TextImage[0].global_position.x = 5

	VisualsCore.FramesPerSecondFrames = (VisualsCore.FramesPerSecondFrames + 1)

	var ticks = Time.get_ticks_msec()
	if (ticks > (1000+VisualsCore.FramesPerSecondLastSecondTick)):
		VisualsCore.FramesPerSecondLastSecondTick = ticks

		VisualsCore.FramesPerSecondArrayIndex = (VisualsCore.FramesPerSecondArrayIndex + 1)
		if (VisualsCore.FramesPerSecondArrayIndex > 9):  VisualsCore.FramesPerSecondArrayIndex = 0

		VisualsCore.FramesPerSecondArray[VisualsCore.FramesPerSecondArrayIndex] = VisualsCore.FramesPerSecondFrames

		VisualsCore.FramesPerSecondFrames = 0

		VisualsCore.FramesPerSecondAverage = 0
		for index in range(0, 10):
			VisualsCore.FramesPerSecondAverage+=VisualsCore.FramesPerSecondArray[index]

		VisualsCore.FramesPerSecondAverage = (VisualsCore.FramesPerSecondAverage / 10)
		VisualsCore.FramesPerSecondAverage = floor(VisualsCore.FramesPerSecondAverage)

		if (ScreenToDisplay == PlayingGameScreen):
			VisualsCore.FramesPerSecondText.TextImage[0].text = ( " "+str(VisualsCore.FramesPerSecondAverage)+"/"+str(LogicCore.GameSpeed) )
		elif (ScreenToDisplay != PlayingGameScreen):
			VisualsCore.FramesPerSecondText.TextImage[0].text = (" "+str(VisualsCore.FramesPerSecondAverage)+"/30")
else:
	VisualsCore.FramesPerSecondText.TextImage[0].global_position.x = -9999

pass


There is also a Engine.get_frames_per_second() which will report the current framerate in FPS. You don’t have to calculate your own moving average.

You aren’t calculating the overshot, if your ticks is over 1000ms from the last, you only reset the comparing value to the current tick, not carrying over any excess time. Maybe it won’t fix the issue, but you should use the engine’s built in framerate check anyways.

Just uploaded Web HTML5, and Linux x86_64 versions to Itch.
Game is open-source and the full project can be downloaded on Itch as well.

We will try OBS Studio to record video of the game, thanks!