setTag Issues

Hello All,

I have a question regarding using the setTag function on nodepaths. I’m setting a tag on a nodepath to allow for collision detection. Because of the nature of the game I’m making I need to switch that tag sometimes during the course of the game. The problem I’m running into I think is that each time I’m ‘changing’ the tag I’m actually just adding a new tag to the list of tags on the nodepath. This eventually causes me a problem with collision detection where when I hover over one piece it highlights another.

The solution I think is to remove any tags on the nodepath and then add the new tag. Unfortunately I’m not sure how to remove the existing tags on the node path.

For reference I’m using Panda 1.7 and the line of code I’m using to set the tag in the first place is:

self.hand1card[self.hiHex-127].find("**/Hex").node().setTag('hand1', str(self.dragging-127))

Any help is very much appreciated,

Craig Wells
Graduate Student
ETC

For a given node, there is only one tag for a particular key. Thus, if you say nodePath.setTag(‘hand1’, ‘one’), and then later, on the same nodePath, do nodePath.setTag(‘hand1’, ‘two’), you have replaced the previous tag value of ‘one’ with the new tag value of ‘two’. The previous tag value is no longer there.

For the record, though, you can remove a tag value with nodePath.clearTag(‘hand1’).

If you’re finding that old tags are accumulating, perhaps you are applying the setTag() operation to different nodes each time?

David