Issue with setting Tags

I realized that I was setting a tag to an Actor’s geometry, when it fact I should have had setCollideMask(0) on that geometry. The Actor is attached to a PandaNode.

What I really wanted to do was create a collision sphere to represent collision with the actor. So I made a collision sphere and attached it to the PandaNode, along with the Actor’s geometry.

The problem is, I haven’t found a way to set a tag to the Collision Sphere, since collision with the sphere is to represent collision with the Actor’s geometry.

Is it even possible to set a Tag to a collison solid defined in P3D? If so, how? I could not get it to work.

You can set a tag on any node in Panda. That means you can set a tag on the CollisionNode that contains your CollisionSphere.

I don’t understand most of the rest of your question, sorry.

David

Hum…? Why couldn’t I get it to work?

self.BodCol = self.ObjInst.attachNewNode(CollisionNode('Fem1aBodDetect'));
self.BodColObj = CollisionSphere(0, 0, 0, 3);
self.BodCol.node().addSolid(self.BodColObj);
#self.BodColH = CollisionHandlerQueue();
self.BodCol.show();


LittleAct = Actor_Fem1a();
LittleAct.BodColObj.setTag("Pickable", str(LittleAct));

Your code looks valid to me, you set a tag “Pickable” to have a value of the string representation of “LittleAct” which is likely to be something like “<Actor_Femla instance at 0xblahblahblah>”, perhaps you actually wanted to give a reference to that class, instead of just that jumbly useless string name?

Try using setPythonTag instead, then you can pass a python - type reference to the class, and store that so that you can retrieve it later using LittleAct.getPythonTag, in that case you could do something like this:

LittleAct = Actor_Fem1a()
LittleAct.BodColObj.setPythonTag("Pickable", LittleAct)

Later retrieve it as this:

LittleAct = myPreviouslyPickedBodyColObj.getPythonTag("Pickable")
LittleAct.doSomethingOrAccessVariablesOrMethodsHere()

Also as a note, semicolon’s (’;’) are non-required in python (completely optional), if you like it though that’s cool too, just thought I’d mention it

Hope this helps,
~powerpup118

I’m actually making very good use of that string value. :smiley:

I gave up on trying to set a Tag to a collision sphere. It wasn’t as big of a deal once I was able to get my Picking Ray to stop its collisions once the picking was done.

Even though the geometry of my actors will have to be calculated for collison when my Picking Ray hits them, the frame rate doesn’t really change anymore because such a collision happens once and stops now; unlike before, the picking ray just kept registering the collision.

You can’t set a tag on BodColObj, which is just a CollisionSphere. Do it on the CollisionNode instead, which is BodCol. Or use the actor itself.

David