Godot Version
v4.2.1.stable.mono.official [b09f793f5]
Question
As per title, I’m trying to find all objects with a specific script attached. The way I’m doing it now is that I set up a group in wich I put all the objects I want, and then use GetNodesInGroup. Problem is that this only gives me access the node, not the script, so this is the solution I came up with:
var nodes = GetTree().GetNodesInGroup("Player Character");
foreach(Node n in nodes)
{
if (n is Character) party.Add(GetNode<Character>(n.GetPath()));
}
This works, but feels a bit hacky, So I was wondering if there was a better way?