How do you get all nodes of a certain class?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DanielLC

I need the equivalent of Object.FindObjectsOfType() from Unity, where I get every object running that class or a subclass of it. I can’t find out how to do it anywhere. I’ve found get_tree().get_nodes_in_group(), but apparently a group isn’t referring to a class because I’m getting an empty list.

:bust_in_silhouette: Reply From: sash-rc
func findByClass(node: Node, className : String, result : Array) -> void:
  if node.is_class(className) :
  for child in node.get_children():
    findByClass(child, className, result)

func test() -> void:
  var res = []
  findByClass(self, "Control", res)