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 them.
myObject.setPythonTag([tagName], [tagContents])
To get the contents of the PythonTag
, use getPythonTag
.
myObject.getPythonTag([tagName])
A PythonTag
can contain any Python object in it. Strings, numbers, class instances, anything goes.
Note that using...