collisionEntry.getSurfaceNormal() problems

When I use collisionEntry.getSurfaceNormal(), for which I have a collisionRay setup to collide with the terrain, the normalized vector is always (0, 0, 1). collisionEntry.getSurfacePoint() works fine and my character follows the terrain properly, but I cannot seem to get the normal. Any ideas on what silly mistake I might be making? Thanks.

I’m assuming the terrain that you’re colliding with is a series of CollisionPolygons. If it’s something different, there may be a different answer.

Do you have the “level” flag set in your egg file that defines the terrain polygons? That will make the effective normal be 0 0 1, so that there is no tendency for objects to slip off of the surface.

You can test this by setting:

respect-effective-normal 0

in your Config.prc file. That should reveal the proper normal to getSurfaceNormal().

You can also query the normal of the polygon explicitly with something like colEntry.getInto().getNormal(). Of course that only works if the collision surface is a CollisionPolygon mesh.


Thank you! This worked perfectly.