CollisionHandlerFloor :: distance to ground

Hello folks:

Is there a simple (or not so simple) way to get the distance from character to the ground when you are using the CollisionHandlerFloor? Using CollisionRay on character’s feet

According to the API, there is only functions for reach, offset and velocity.

Will I need to user CollisionHandlerQueue? =/


You will need to get the CollisionEntry from the detected collision. You already have this CollisionEntry in the function that processes the collision results, whatever kind of collision handler you are using. If you are using a CollisionHandlerFloor, then it generates an event that you can listen for to find the CollisionEntry.

If all you want is the nominal distance to the floor when the character is generally standing around, that’s the offset parameter. But if you want to differentiate between falling and standing, you’ll need to listen for collision events.


Hello David,

Thanks a lot for answering. Yes, that’s what I thought it will be like, just probing the collisionhandler to get the info that… must be somewhere in it.

But, so far the only reference for CollisionEntry I can get is from the CollisionHandlerQueue, and I’m currently using the CollisionHandlerFloor.

I’ve checked the “Inheritance Tree” from the API and there doesn’t seem to be a .getEntries() =/

Right, the CollisionHandlerFloor doesn’t save up the collision entries in the way that CollisionHandlerQueue does. But it does send them to you so you can query them if you want.

CollisionHandlerFloor inherits from CollisionHandlerEvent, so you can program events that are generated when collisions are detected. It’s then your responsibility to listen for those events with the accept() call. The event will receive a parameter, which is a CollisionEntry object; you then have to decide what to do with that object.


Yup, there we go =)

I’m glad it didn’t involve hacking classes or anything, I come up with basically this:

base.cTrav = CollisionTraverser()
base.floor = CollisionHandlerFloor()

#This node is attached to my character
cNode = CollisionNode('heroRay')

#This one to the floor
cNode = CollisionNode('floor')

#Just worry about things crashing into you

#If our hero (crash)-lands into you, call "collide"
self.accept('heroRay-into-floor', self.collide)

def collide(self, entry):
    print entry


I think I can work my way from here, there is good doc and examples on the CollisionEntry.
Thanks a lot David!