The intention here is ambiguous; fully disabling a node implies more than just not rendering the node, it would also entail preventing any kind of interaction with that node, and stopping any processes running on that node.
To fully stop a node and all its children from rendering, processing, receiving input et cetera, the simplest way is to pull this node out of the scene tree:
var my_node = $SomeNode
func _ready():
remove_child(my_node)
Then, to re-enable:
add_child(my_node)
Be careful with this, as Godot does not garbage collect Node
s, so if you somehow lose a reference to this node, it will hang around in memory for the remaining lifetime of the game.
You can still call functions on this node even while it is outside of the scene tree, but if you try to manipulate anything to do with the node that depends on it being inside of the scene tree, Godot may complain (e.g. you can't move_and_slide()
a KinematicBody
while it's outside of the tree.)
If you only want to disable some aspects of the node and not others, or your game depends on this node remaining in the scene tree always, or you want to disable a parent node but not its children, you can set the callbacks for the node (on top of setting visibility if you want that):
set_process(false)
set_physics_process(false)
set_process_input(false)
You can also require some boolean to be active for certain things to fire:
func _process(delta):
if is_active():
...
func is_active():
return this_cond and that_cond and that_cond_over_there