Search code examples
pythonpython-3.xpanda3d

Collision handeling in Panda3D with traverse()


I am new to Panda3d and I am using some of the 'roaming ralph' code to check for collisions:

In the 'roaming ralph' code example that comes with panda3d, it says

    # Normally, we would have to call traverse() to check for collisions.
    # However, the class ShowBase that we inherit from has a task to do
    # this for us, if we assign a CollisionTraverser to self.cTrav.

I am using the normal version of Showbase, so how do I call

    traverse()

Like it says?


Solution

  • It's saying that if you assign the CollisionTraverser instance to base.cTrav, or self.cTrav, there is no need to call the traverse function every frame. Indeed, this is the case in the Roaming Ralph program.

    If this weren't the case, for example if you rename the variable to self.traverser, you would have to add a line like this to a task (eg. to the existing move task):

    self.traverser.traverse(self.render)