C# - Disabling and enabling process

Godot Version 4.4 Stable

Question

In the case where a node is not supposed to operate and perform any action which disablement approach is better?

SetProcess(value);
SetPhysicsProcess(value);

or

if (value) { ProcessMode = ProcessModeEnum.Disabled; }
else { ProcessMode = ProcessModeEnum.Inherit; }

What would be the differences and are there other ways?

1 Like

SetProcess will toggle the _Process function, and SetPhysicsProcess wil disable the _PhysicsProcess.

Which one is better depends ENTIRELY on how your cure is structured and which function you use to process things. Since if you only do things in _PhysicsProcess and _Process is not even overridden, then SetProcess will do nothing, as _PhysicsProcess will continue to execute your logic inside it.

And as for which way to disable or enable it, as far as I know it depends on how you structure your nodes. The second way has a bit more control.