Problem with collision detection


I want the car in my game to drive over uneven terrain. For now I added this line in the code of my street.egg file:


<CoordinateSystem> { Z-Up }

<Group> character {
  <Dart> { 1 }
  <Group> "Scene Root" {
    <Group> street { 

      <Collide> { Polyset keep descend }

      <VertexPool> street.verts {
        <Vertex> 0 {
          -91419.6 5516.13 -543.893
          <Normal> { 0 0 1 }



is the street now imported twice? one time as a geometry node and one time as a collision node?

for my car i am using a collision ray for now. but unfortunatly no collisions are detected.
To initialize the car as my fromObject i took basicly the code of the roaming ralph tutorial for now.

    def enableCollisionHandler(self):

        self.cTrav = CollisionTraverser()

        self.carGroundRay = CollisionRay()
        self.carGroundCol = CollisionNode('carRay')
        self.carGroundColNp = self.carMain.attachNewNode(self.carGroundCol)
        self.carGroundHandler = CollisionHandlerQueue()
        self.cTrav.addCollider(self.carGroundColNp, self.carGroundHandler)
        # Uncomment this line to see the collision rays
        #Uncomment this line to show a visual representation of the 
        #collisions occuring
        print self.cTrav.getNumColliders()

In the mainLoop I added this code to check if collisions are detected:


print self.carGroundHandler.getNumEntries()

Unfortunatly there are no entries of any collsisions in this list… Does anybody know what I made wrong?

What’s the tag doing there? The street is not an animated character, is it?
Try removing it.

no the street is’nt animated… and now it works :wink: thanks for the quick answer! :slight_smile:

But I have another question to this issue now :slight_smile:

I can query the surface normal of the streetpart my car is colliding with by using the method


Can I use this normal to set the P-Rotation of my car, so that it looks like my car is driving this mountain up?

No - but you can use lookAt for that.

hmm… when I add this lines of code:


It looks to be right when I drive over flat terrain or when I drive the mountain up. But when I drive the mountain down the car unfortunatly rotates wrong… By driving the mountain down the cars rotation-p is nearly 0 so as i am driving on flat terrain…

Try something more like:

self.carMain.headsUp(self.carMain.getPos() + Vec3(0, 1, 0), entries[0].getSurfacePoint(render))