I’m developing a game and I wanted to know if having checks before an action in a process/physics_process loop is more “optimized” than just having an action straight away, does it make any difference perfomance-wise and which method would perhaps run better?
Here’s an example of a check before an action (after else:)
And heres the same code but without a check for if the timer stopped:
This code is running in the physics_process loop and with that in mind, would it be faster to have it constantly check for if the timer is not stopped (and then stop it), or would it be better to just stop the timer constantly every frame?
edit: most of the time the code would return false in the if linear_velocity … , running the “else” code 99% of the time
So it doesn’t seem like this will make a lot of difference on performance.
Whenever you have these types of doubts, try both cases and see if the performance improves or is imperceptible. And take a look at the Godot’s source code, where you will be able to investigate further and find what is exactly happening behind the scenes!