I’m making my first try at using Panda collision detection. To be precise, using the CollisionRay coming from the camera to pick an object. Now, since my game objects are composites of multiple nodes, I really want to pick the thing at the right level. So, presuming that the CollisionEntry will catch a bottom level node, in this case a cube, I want my “pick” to give me, not the cube, but the composite thing some levels above it.
I think I want to do something along the lines of “Get the ancestor of this NodePath that has tag .” Is there an operation for that, or do I need to iterate it myself? Is there a well-known best way of doing this?
I see two ways of doing this, offhand:
First, you can use the “findNetTag” method of NodePath to search for “the lowest ancestor of this node that contains a tag definition with the indicated key”.
And second, you can set Python-tags on your collision-objects, directly referencing their composite objects. (Just be careful to clear your Python-tags once you’re done with them, lest the cyclic reference thus created interfere with garbage collection!) This approach is I believe described in the section of the manual that discusses “Clicking on 3D Objects”.
(I usually use the latter approach, myself.)
That got it. And thank you for that clear manual reference.