Should Nodes and NodePaths always have unique names?

Silly newbie question =) In reading the manual, I notice some conflicting conventions when assigning node names. For example, this page about the physics system contains the following snippet:

node = NodePath("PhysicsNode")
an = ActorNode("jetpack-guy-physics")
anp = node.attachNewNode(an)

As you can see, the node variable has the generic name “PhysicsNode” which only specifies broadly that it’s physics-related. The an variable is very specifically named to show that it is the physics node for the jetpack guy.

At this point I would still have assumed that more specific names are better, and written off “PhysicsNode” as a small oversight. However, the next page of the manual has this line


This makes it sound like the node name is actually more of a “group” name! I could imagine gravity, drag, wind, and other ForceNodes all being given the name ‘world-forces’, perhaps so it’s easy to search for the lot of them later on.

So now I’m not sure. :slight_smile: Is there a “right” way to name nodes? Are they meant to describe exactly the purpose of the individual node, or to put nodes into broad categories? Or, is it just an arbitrary field that I can freely use in whatever way seems best to me? =)

As far as I know, you’re not required to give them unique names, but it is helpful for your own sake. Not only does it allow you to use operations like nodePath.find(’**/my-node-name’), it also gives you an unambiguous way to tell which node it is when you print it out or in the output of

I often use tags if I want to find a group of nodes. For exaple use nodePath.setTag(‘force’) for all nodes of a group, and then use nodePath.find(’**/=force’) to find all node paths with this tag set.