ground collision with collisionpolygon

i have problems with the collisionpolygon and tube…
this one is the poly for the left wall and works:

c1Node.addSolid(CollisionPolygon(Point3(-20, 5, 10), Point3(-20, -5, 10),
                                        Point3(-20, -5, -10), Point3(-20, 5, -10)))

but my “player” doesn’t collide with the poly that should be the ground:

c1Node.addSolid(CollisionPolygon(Point3(-20, -5, -10), Point3(20, -5, -10),
                                        Point3(20, 5, -10), Point3(-20, 5, -10)))

the same happens with collisiontubes.
a tube acting as a wall (vertical) works, but the horizontal tube doesn’t.

any ideas?

greets

this is the whole code i use…
use the wsad-keys to move around

from pandac.PandaModules import *

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject

class Main(DirectObject):
    def __init__(self):
        base.setBackgroundColor(0.0, 0.0, 0.0, 1)
        base.cam.setPos(0,-200,0)
        
        self.keys = {}
        
        base.cTrav = CollisionTraverser()
        pusher = CollisionHandlerPusher()

        smiley = render.attachNewNode("muh")

        c1Node = CollisionNode('smiley')
        c1Node.addSolid(CollisionTube(-5,0,10,5,0,10, 2))
        c1Node.addSolid(CollisionTube(10,0,10,10,0,-10, 2))
        c1Node.addSolid(CollisionPolygon(Point3(-20, 5, 10), Point3(-20, -5, 10),
                                        Point3(-20, -5, -10), Point3(-20, 5, -10)))
        c1Node.addSolid(CollisionPolygon(Point3(-20, 5, 10), Point3(20, 5, 10),
                                        Point3(20, -5, 10), Point3(-20, -5, 10)))
        c1Node.addSolid(CollisionPolygon(Point3(-20, -5, -10), Point3(20, -5, -10),
                                        Point3(20, 5, -10), Point3(-20, 5, -10)))

        smileyC = smiley.attachNewNode(c1Node)
        smileyC.show()
        
        self.frowney = loader.loadModel('misc/sphere.egg')
        self.frowney.reparentTo(render)
        self.frowney.setPos(0,0,0)
        
        cNode = CollisionNode('frowney')
        cNode.addSolid(CollisionSphere(0,0,0,2.0))
        frowneyC = self.frowney.attachNewNode(cNode)
        frowneyC.show()
        
        base.cTrav.addCollider(frowneyC,pusher)
        pusher.addCollider(frowneyC,self.frowney, base.drive.node())
        
        self.acceptMultiKey("a", "left")
        self.acceptMultiKey("d", "right")
        self.acceptMultiKey("w", "up")
        self.acceptMultiKey("s", "down")
        
        self.adda = 0.5
        
        taskMgr.add(self.movePlayer, "movePlayer")
        
    def movePlayer(self, task):
        factor = globalClock.getDt() * 100.0 * self.adda
        if self.keys["left"]:
            self.frowney.setFluidX(self.frowney.getX()-factor)
        if self.keys["right"]:
            self.frowney.setFluidX(self.frowney.getX()+factor)
        if self.keys["up"]:
            self.frowney.setFluidZ(self.frowney.getZ()+factor)
        if self.keys["down"]:
            self.frowney.setFluidZ(self.frowney.getZ()-factor)
            
        self.frowney.setFluidY(0)
        return task.cont
    
    def acceptMultiKey(self, key, val):
        self.setKey(val, 0)
        self.accept(key, self.setKey, [val, 1])
        self.accept(key+"-up", self.setKey, [val, 0])
          
    def setKey(self, key, val):
        self.keys[key]=val
        
if __name__ == '__main__':
    m = Main()
    run()

If your player is a CollisionHandlerPusher, make sure you have called setHorizontal(True) on it.

hmmm still doesn’t work:

pusher = CollisionHandlerPusher()
pusher.setHorizontal(True)

i added an “addInPattern” to the pusher, which gives me an event, when i collide with the ground, but no pushing happens…hmmmm

Actually, you want to call setHorizontal(False).

David

lol! i really thought about setting it to False, but it seemed not to be logic to me.
thanks david, it now works like a charm.