_Process and _PhysicsProcess: time, enabling and pause
A working two-callback counter: delta, independent toggles and UI that stays active while paused.
Choose a callback
_Process runs in the ordinary frame loop with variable delta; _PhysicsProcess runs in the physics-tick loop. physics/common/physics_ticks_per_second sets frequency, but a long frame can need several ticks and a catch-up limit bounds the work. Do not assume one physics callback per rendered frame.
| Task | Usually suitable |
|---|---|
| Physics CharacterBody control | _PhysicsProcess with body movement methods |
| Continuous physics force | Physics ticks; the force method already integrates time |
| Counter/UI refresh | _Process, events or a timer as needed |
| Manual camera following visual state | A deliberate per-frame interpolation-aware scheme |
| Expensive HTTP/file/long computation | A separate asynchronous/background mechanism, not blocking every frame |
delta uses game-time seconds and depends on time settings. For direct Position changes, add speed × delta. Set MoveAndSlide Velocity without another delta; change velocity from acceleration with delta. Use the callback argument; GetProcessDeltaTime/GetPhysicsProcessDeltaTime are not separate wall clocks.
Run the counters
Add ClockProbe.cs and ProcessingClockDemo.cs. Create a separate Control-root level, attach ProcessingClockDemo, build and press F6. Use a 640×420 or larger window. Counters show calls and summed delta, not whole-game performance.
The first button toggles only Probe _Process; the second only _PhysicsProcess. Pausing stops both Probe counters while UI stays active to resume. UI uses Always and Probe explicitly uses Pausable rather than inheriting. Removing the example restores the previous EntityTree.Paused value.
ClockProbe.cs
using Reckfell;
public partial class ClockProbe : Entity
{
public int Frames { get; private set; }
public int Ticks { get; private set; }
public double FrameSeconds { get; private set; }
public double PhysicsSeconds { get; private set; }
public override void _Process(double delta) { Frames++; FrameSeconds += delta; }
public override void _PhysicsProcess(double delta) { Ticks++; PhysicsSeconds += delta; }
}ProcessingClockDemo.cs
using Reckfell;
public partial class ProcessingClockDemo : Control
{
public ClockProbe Probe { get; private set; } = null!;
public Label Status { get; private set; } = null!;
private bool _initialPause;
public override void _Ready()
{
ProcessMode = ProcessModeEnum.Always; _initialPause = GetTree().Paused;
Probe = new ClockProbe { ProcessMode = ProcessModeEnum.Pausable }; AddChild(Probe);
var box = new VBoxContainer { Position = new Vector2(24,24) }; AddChild(box);
Status = new Label(); box.AddChild(Status);
AddButton(box, Text("Переключить _Process", "Toggle _Process"), () => Probe.SetProcess(!Probe.IsProcessing()));
AddButton(box, Text("Переключить _PhysicsProcess", "Toggle _PhysicsProcess"), () => Probe.SetPhysicsProcess(!Probe.IsPhysicsProcessing()));
AddButton(box, Text("Пауза мира", "Pause world"), () => GetTree().Paused = !GetTree().Paused);
}
private static string Text(string ru,string en) => TranslationServer.GetLocale().StartsWith("ru") ? ru : en;
private static void AddButton(VBoxContainer box,string text,System.Action action)
{
var button = new Button { Text = text }; box.AddChild(button); button.Pressed += action;
}
public override void _Process(double delta)
{
Status.Text = $"_Process: {Probe.Frames} / {Probe.FrameSeconds:F2}s\n_PhysicsProcess: {Probe.Ticks} / {Probe.PhysicsSeconds:F2}s\nPaused: {GetTree().Paused}";
}
public override void _ExitTree() { GetTree().Paused = _initialPause; }
}Enabled flags and effective processing
Overridden script callbacks are enabled for processing automatically. SetProcess and SetPhysicsProcess toggle separate flags. IsProcessing/IsPhysicsProcessing expose enabled state, while pause/ProcessMode can prevent actual calls. For missing callbacks, check tree membership, mode, pause, flags and the correct override signature.
Always permits paused processing; it does not bypass every time setting or authorize arbitrary worker-thread access. Inherit takes the parent mode; define clear pause-menu/world boundaries. Disabling _Process does not automatically disconnect every child button signal, allowing separate handlers to re-enable a counter.
Do not log every frame merely to observe behavior: logging adds work. Refresh a compact indicator or collect a bounded trace. Use suitable Timers/events for periodic actions and coordinate interpolation for physics motion. Pause, callback disabling and entity deletion are distinct states.