@cybereality said:
However, I usually just use a boolean value like "is_active" and wrap the update code in an if statement:
func _process(delta):
if is_active:
# all the game code here
I often use this to pause functionality as well, though I generally check for it being false and returning to stop executing functionality:
func _process(delta):
if is_active == false:
return
# all the game code here
But it's basically the same technique, just a different way of writing it.
Sometimes it can helpful to use visible
to disable/enable functionality, as then you can disable functionality easily from other scripts and animations. The downside of using visible
though is that it's harder to debug and you have to set visible
to false
on the node itself to disable functionality, even if the parent node is not visible.
For example:
- Parent (visible)
- Child (not visible = not executing)
- Parent (not visible)
- Child (visible = executing even though its parent is not visible)
But I find it can be helpful and an easy to to track if something should be executing by just checking it's visibility.