It Demonstrating how you can use the VisibilityNotifier2D (which works the same way as VisibilityNotifier for 3D)
The VisibilityEnabler will disable RigidBody and AnimationPlayer nodes when they are not visible. It will only affect other nodes within the same scene as the VisibilityEnabler itself."
Note this is a very old question and refers to an older version of Godot. Make sure to check the date of questions you’re answering.