Animate or _process()?

Godot Version

4.6.3

Question

I’m revisiting my “first game release” from a couple years ago. I am going to move several chunks of code out of physics_process().

I have a propeller that is always in the 3rd person camera view. I currently rotate it every physics_process() with the code below.

For constant movement like this, would it be more CPU/graphics efficient to move the code to _process() or to setup an animation?

if not is_crashing:
		propeller_shaft.rotate_z(deg_to_rad(propeller_speed))	#Rotate the propeller

Assuming the propeller_shaft isn’t a physics body, _process would be better, and multiply your rotation by delta to operate per-second instead of per-frame

This is the wrong thing to optimize.

The cost of the actual rotation is the same either way, so what’s left is basically the overhead of using GDScript at all. GDScript isn’t free. Putting these two lines in C++ instead of GDScript would let them run several times faster (ignoring the cost of the actual rotation). But, your project is presumably full of GDScript, so the cost of these two lines is negligible in the big picture. And using an AnimationPlayer node isn’t free either.

If you’re seriously trying to optimize your project, measure where the actual bottlenecks are, optimize those, ignore everything else, and measure again every time you make a change to see if your change actually helped or made things worse. If you’re not seriously trying to optimize, focus on readability and robustness over performance.

Those two lines can actually be delegated to C++ code by animating the rotation using a tween.