Get delta time outside _process?

Is it somehow possible to get the delta time outside of _process?

The only idea I had is to create a singleton or autoload where I get the delta time from. But I want to avoid this.

Like, create a variable at the script scope then set it from the process function. Would that work for you?

var delta: float

func _process(_delta: float) → void:
delta = _delta

1 Like

You can also use


extends Node2D

func step():
    position.x += speed * get_process_delta_time()

You can also get delta globally with:

var delta: float = Engine.get_main_loop().root.get_process_delta_time()

Edit: Added how to get delta globally.


I thought about this too. But I wanted to have delta in a function in a class that extends RefCounted and have only the node as argument, so indicainkwells solutions is exactly what I was looking for. Thanks for the suggestion. :slight_smile:

1 Like

Thanks! I didn’t know this existed. Exactly what I was looking for!

1 Like