Skip to content

Documentation for SceneTree.get_frame is misleading #90539

@MajorMcDoom

Description

@MajorMcDoom

Tested versions

Reproducible in 4.2 and 4.3.dev

System information

Godot v4.2.1.stable - Windows 10.0.22631 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 1660 SUPER (NVIDIA; 31.0.15.5212) - Intel(R) Core(TM) i7-10700F CPU @ 2.90GHz (16 Threads)

Issue description

The naming and documentation for SceneTree.get_frame() suggests that it is plainly the "frame count". But in reality, it is actually the physics frame count specifically. There's nothing currently to tell the user this, and it's quite confusing, and leads to bugs.

Not sure if the solution would be to fix the documentation/naming, to change the way this number is incremented in SceneTree, or simply to remove the method completely, since there are already Engine.get_process_frames() and Engine.get_physics_frames().

Steps to reproduce

If you run this code:

func _process(delta: float) -> void:
	prints("_process", get_tree().get_frame())

func _physics_process(delta: float) -> void:
	prints("_physics_process", get_tree().get_frame())

You get output like this:

_physics_process 1
_physics_process 2
_process 2
_physics_process 3
_physics_process 4
_physics_process 5
_physics_process 6
_physics_process 7
_physics_process 8
_physics_process 9
_process 9
_process 9
_process 9
_process 9
_physics_process 10
_process 10
_physics_process 11
_process 11
_physics_process 12
_process 12
_physics_process 13
_physics_process 14
_process 14

Notice how the frame count is only incremented with the physics step, and not with the process step.

Minimal reproduction project (MRP)

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions