Should I set physics process to false when not in use?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By raKdoS

Example

func _on_body_entered(body: Node) → void:
set_physics_process(true)

func _on_body_exited(body: Node) → void:
set_physics_process(false)

:bust_in_silhouette: Reply From: kidscancode

For what purpose? You should never make assumptions about optimization, you are most likely just wasting your time.

If you are having a performance issue, you must profile your code and identify exactly what is causing the problem. Without doing that, you’re just adding unnecessary code and doing nothing at all, or even possibly causing more problems down the line.

In short: don’t worry about it.