Accessing faces from the GE

I tried in the python forum but got no response so maybe someone here can help instead.
Does anyone know how from in the game engine you can get the face a charcter is above or in collision with.
If there is no way of doing it with a raycast or simaler thats fine I’ve got a back up plan but I don’t wan’t to hack a slooow solution together when there’s a quick and easy fix.

I don’t know of any way of getting the face, but object and hit position and normal of the face.

If you explain what you’re trying to do, we can probably help you more.

You can find, as Sim88 said, where a ray hit an object, the object that it hit, and the normal (orientation) of the face. This can be accompished with hitPosition, hitObject, and hitNormal. For example, if you had a ray sensor called “ray” (without quotes) and it was attached to this python script:


c = GameLogic.getCurrentController()
own = c.owner
ray = c.sensors['ray']

own.alignAxisToVect(ray.hitNormal)

It would align your object’s orientation to whatever the ray was hitting… if the ray was pointing downward, your object would be aligned to the ground.

-Sam

Okay, I shall reveal all.
I’m writing a pathfinder that uses navigation meshes. Ambitious yes but none the less doable. I’m a fair way through it, allthough it’s tough to tell what works fully without testing more.
I’l get slightly technical now so bear with me. Pre playing the game a mesh is converted into bits to be used by the pathfinder. The faces are essentially nodes and the edges that connect faces are ‘portals’, using some python shenanigons I then create instances of a node class where each node stores it’s own position, connected nodes as a dictionary of adjacent nodes and distances to them, and owned portals.
My A* then runs using these node objects and then a path is built of portals. The nodes in the path share.
That’s where I’m up to at the minute. After I’ve fully tested I need to add smoothing and other bits, will probably add terrain cost based on mesh colour. This is what I’m trying to acheive. http://www.ai-blog.net/archives/000152.html
Anyhow back to the problem in hand because the face can be large to cover a large area if you are on the edge of this area and the next face is small it is possible the nearest node would not be the node you’re stood on. Hence nearest doesn’t work for getting your start/end node hence I wanted an easy way to access this node. As I said I do have a method that works I just wanted to check for a simpler solution. Prizes for those who can guess my solution lol, bonus prizes if the solutions better than my own :-).