Mutliple _process_physics functions and when to call move_and_slide

Godot Version

v4.2.2.stable.official [15073afe3]


Hi everyone,

I have two functions in a script: one is just plain _physics_process (1), the other is handle_movement and is called by the _physics_process (2) from another script.

Should I call move_and_slide in both _physics_process (1) and handle_movement, or just _physics_process (1) which works fine but will maybe result in handle_movement executing a tick behind, or do something else?

You should be calling move_and_slide once per frame. So call it just in 1 method. You can decide which one, it is not mandatory to be in _physics_process, you can use it just in handle_movement which is called from a _physics_process from another node I assume.

1 Like

Thanks a lot for the quick reply!

I’ll have it in _physics_process since it’s the method that always runs regardless of whether the game is paused or not

You can control if a node is pausable or not.
Each node has a property, if you look at the bottom of porperty inspector, in section “Process”, there is a combo for property “mode”. You can turn it to Always, so it runs even when the game is paused.

1 Like

Yeah I knew about that but that’s not the way I wanted to do it thought :frowning:
Thanks anyways

1 Like