O'Reilly logo

Panda3D 1.6 Game Engine by Dave Mathews

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Python tags to get colliding objects

Very commonly, games developers will want to be able to get a reference to the objects that have collided so they can modify some attribute of one or the other, such as a character taking damage when they are hit by an attack. In Panda3D, we can easily get the From and Into CollisionNodes from the collision entry with getFromNodePath and getIntoNodePath.

myCollisionEntry.getFromNodePath()
myCollisionEntry.getIntoNodePath()

But, that doesn't give us the class instance that actually owns the CollisionNode. For that, we need to attach a reference to the class instance to the CollisionNode using PythonTags.

A PythonTag is a way to attach a reference of one thing to another. We use setPythonTag to create ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required