Problem walking on ground.

Hey everyone.
been a while, but im back now, with a new question.
(probably a silly one again)

here goes:
i am writing an rpg game. i used the roaming ralph code for walking on ground, but it wont detect any collision between the ground and the collisionray…

ignore all the dutch comments (it is a school project) :wink:

here is the terrain code:

    def worldgenerate(self):
	tex = loader.loadTexture('colormap.png')
	self.terrain = GeoMipTerrain("Terrain")
	self.terrain.setHeightfield("heightmap.bmp")
	#self.terrain.setAutoFlatten(GeoMipTerrain.AFMLight)
	#self.terrain.setBruteforce(True)
	self.terrainnode=self.terrain.getRoot()
	self.terrainnode.setPos(-2000,-2000,-25)
	self.terrainnode.setSz(300)
	self.terrainnode.setCollideMask(BitMask32.bit(2))
	self.terrainnode.reparentTo(render)
	self.terrainnode.setTexture(tex)
	self.terrain.setBlockSize(64)
	self.terrain.setNear(128)
	self.terrain.setFar(1024)
	self.terrain.setFocalPoint(base.camera)
	self.terrain.setMinLevel(3)
	self.terrain.generate()

works fine to me.

this creates the ray (stripped from ralph):

    def setupcollisionHW(self):
	self.cTrav = CollisionTraverser()


        self.HPGroundRay = CollisionRay(0,0,1000,0,0,-1)



        self.HPGroundCol = CollisionNode('HPRay')

        self.HPGroundCol.addSolid(self.HPGroundRay)

        self.HPGroundCol.setFromCollideMask(BitMask32.bit(2))

        self.HPGroundCol.setIntoCollideMask(BitMask32.allOff())

        self.HPGroundColNp = self.hoofdpersoon.attachNewNode(self.HPGroundCol)

        self.HPGroundHandler = CollisionHandlerQueue()

        self.cTrav.addCollider(self.HPGroundColNp, self.HPGroundHandler)


	self.HPGroundColNp.show()
	self.cTrav.showCollisions(render)

and this checks the stuff and moves the character around (also stripped from ralph):

    def move(self, task):

	speed=10
	if (self.controls["crawl"]):
	    speed=.5
	elif (self.controls["run"]):
	    speed=1.5
        if (self.controls["forward"]):

            self.hoofdpersoon.setY(self.hoofdpersoon, speed*-15 * globalClock.getDt())

	if (self.controls["backward"]):

            self.hoofdpersoon.setY(self.hoofdpersoon, speed*15 * globalClock.getDt())

        if (self.controls["left"]):

            self.hoofdpersoon.setX(self.hoofdpersoon, speed*7 * globalClock.getDt())
	if (self.controls["right"]):

	    self.hoofdpersoon.setX(self.hoofdpersoon, speed*-7 * globalClock.getDt())
	#check voor collision tussen de self.HPGroundRay en de wereld
	self.cTrav.traverse(render)
	#zet alle gevonden collisions in een lijst, sorteer deze en vraag de eerste waarde op
	self.entries = []


	for i in range(self.HPGroundHandler.getNumEntries()):

            entry = self.HPGroundHandler.getEntry(i)

            self.entries.append(entry)

        self.entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(),

                                     x.getSurfacePoint(render).getZ()))

	#als de eerste gevonden collision met de wereld is (kan niet anders)
	#zet de hoofdpersoon op de Z van het punt van collision
        if (len(self.entries)>0) and (self.entries[0].getIntoNode() == self.terrain):

            self.hoofdpersoon.setZ(self.entries[0].getSurfacePoint(render).getZ())

	return task.cont

i set the ray to be shown, but it wont show up. (maybe because it is thought of as having 0 thickness)

all help appreciated.

by the way, i printed out the self.entries[], but it is empty.

Ńo need for collisions, use getElevation. Check this out: www.panda3d.org/forums/viewtopic.php?t=11206

ill give that a try when i get home, but in the meantime it would be nice to know why this here isnt working the way it should.

allright, so i tried that, but its not even closely accurate enough. the character keeps walking in or above the ground and sorta “jumps” up and down to get there. i need it to be smoother.