Correct, I’d also use exported values if possible. But that isn’t flexible enough in some cases, because you’d need to individually export all possible attributes that the node might have.
For it to be more flexible, you could have something like this:
for child inget_children():
if child is ClassNameHere:
return child
That would give you the same result as described in the article, without string reference. You could make a static func for it and call it a day :)
@mrsgreenpotato what case do you have in mind where an export is not flexible enough? Also, do you return a Variant or generic Node(2D/3D) of a function like that or are you working with Generics then? So you do: GetNode<Bumpable>() for example?
Correct, I’d also use exported values if possible. But that isn’t flexible enough in some cases, because you’d need to individually export all possible attributes that the node might have.
For it to be more flexible, you could have something like this:
for child in get_children(): if child is ClassNameHere: return child
That would give you the same result as described in the article, without string reference. You could make a static func for it and call it a day :)
@mrsgreenpotato what case do you have in mind where an export is not flexible enough? Also, do you return a Variant or generic Node(2D/3D) of a function like that or are you working with Generics then? So you do: GetNode<Bumpable>() for example?