CollisionHandlerPusher. i don't understand

i try use Collision System but i wrong use it: doesn’t work. i write this

from direct.showbase.ShowBase import ShowBase
from pandac.PandaModules import loadPrcFileData 
from panda3d.core import *
from pandac.PandaModules import * 
from direct.gui.DirectGui import * 

class MyApp(ShowBase):
    def __init__(self):
       , -5, 2)
        self.cTrav = CollisionTraverser()
        pusher = CollisionHandlerPusher()
        = self.loader.loadModel("models/smiley"), 0, 4), 0.25, 0.25)
        fromObj ="Smile"))
        fromObj.node().addSolid(CollisionSphere(0, 0, 0, 1.25))
        self.cTrav.addCollider(fromObj, pusher)
        wall = self.loader.loadModel("models/box")
        wall.setPos(-0.5, -0.5, -0.5)
        taskMgr.add(self.updatePlayer, "updatePlayer")
    def updatePlayer(self, task):,,*task.getDt());
        return task.cont
app = MyApp()

but i don’t know where i wrong.
I create a CollisionTraverser and a CollisionHandlerPusher. I load a smile and make it a from object. i load a wall that, as default, is a into object. The smile move to wall thought a task function.
Who can help me?

You almost have it. There are just two different problems:

(1) The box.egg model that you use doesn’t have any collision geometry inside it, it’s just visible geometry. You ideally want an egg file that includes special geometry that is tagged with the flag so that it defines the solid walls.

However, you can use it anyway; it’s possible to use visible geometry as collision geometry. This is very expensive, though, so you would only do this as a shortcut when you don’t have time to make a special model and you don’t care about performance. To do this, you just set the collide mask on the visible geometry to have at least one bit in common with your from object, by adding a line like this:


(2) For historical reasons, CollisionHandlerPushers all have the default setting for the “horizontal” flag to be true, which means they will respond only in the XY plane–Z is eliminated. Unfortunately, you are moving the model entirely in Z in this example, so you will need to turn off the horizontal flag:


This flag is terribly confusing, so I think I will change the default to false for 1.8.

(3) This isn’t a problem, really, but if you want to avoid the appearance of bouncing when you reach the target, you should position the camera after the collision traversal as adjusted the position. Change your task so that the traversal and the camera lookAt() occur in this order:



Thanks!!! I try it asap

what do i add in the egg file to make the mesh a collider?!?!?!

The complete answer is complex, but the short answer is put { polyset keep descend } within the that contains the polygons you are interested in.


Where can i read more of this argument? Or how can i export a mesh from blender with collide tag?
And thanks for all :slight_smile: