Edit 2 : Updated code, so runnable zip isn't the same as the copied section bellow (though all that has changed is that part in run_me.py)

Edit: Runnable zip with source files, sorry: https://dl.dropboxusercontent.com/u/12781104/Collisions.zip

Right now I am trying to create a small room for my character to walk around in, it works decently but will walk through walls, I am having difficulty setting up the collision logic to stop the character from walking through walls. The problem is properly creating the collision plane to line up with the walls (is there a way to do this in blender?)...

Code so far that has to do with wall collisions

 [Removed imports]


    self.cTrav = CollisionTraverser()
    robotCHandler = CollisionHandlerQueue()
    robotWallCHandler = CollisionHandlerPusher()


    ralphStartPos = (0, 0, 0)
    self.ralph = loader.loadModel("robot.x")
    # setup tube to suround robot
    #(robot is 3 height, by 1.5, 1.5)
    cTube = CollisionSphere(0, 0, 0, 3)

    robotCollisionNode = self.ralph.attachNewNode(CollisionNode('robotcnode'))

    self.environ = loader.loadModel("room2.x")

    root = self.environ.find("**/Root")
    walls = root.findAllMatches("**/Plane*")

    for w in walls:
        # set it to the same bitmask so the collider collides

    robotWallCHandler.addCollider(robotCollisionNode, self.ralph)

    self.cTrav.addCollider(robotCollisionNode, robotWallCHandler)

The bottom line is what I am most confused about, how do I get the collision plane properly setup, do I just have to hard code the points or is there something easier (maybe the geom nodes?)?


1 Answer 1


You should be able to export the collision data from Blender without any setup necessary in Panda3D (no setIntoCollideMask). Go to the Logic panel, then add a String property called "Collide" set to "Polyset keep descend". Do this for all your wall objects that you want to be collideable, and it will work out of the box.

If you would like to keep your collision geometry separate from the visible geometry, you can do that too, you'll just need to set the property to "Polyset descend" to tell Panda that that mesh is only to be used as collision geometry and not as visible geometry.

  • \$\begingroup\$ What if I want to add, programmatically, the collision attribute to every object (3d building) I have on my blender model? I am trying to use this panda-utils module, so setup an assset pipeline, but without success. \$\endgroup\$ Nov 5, 2023 at 16:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .