Get the highest face of a mesh


I would like to display arrows on some of the characters (see image 1).
I could do it without any problem :

  • find the character’s position
  • add arrow, orient towards camera

The problem is that the character’s position is given by his central point.
So, if I add my arrow, i get the issue on image 2.
I can’t define arrow’s Z position like arrow’s Z position = character’s Z position + 5 (example) because it’s obviously not working well with little characters.

The last solution would be to add empties for each character to define the arrow’s position.
But I would like to be able to get the highest face and add the arrow and see if it’s a good solution first.
(I’m well aware that getting the highest face is not a solution in all cases : fighting a dragon that has a long tail).

Thank you


Use the KX_GameObject .meshes attribute to get a proxy of the mesh of the object.

From there you could iterate through either getPolygon() (then iterate through it’s vertices) or getVertex() of the KX_MeshProxy object:

Then you simply save which one has the highest Z value, and that’s your highest point. So simply place your arrow there.

But imho I think in most cases you’d prefer using an empty. Because this is not the only use for having an empty on the character’s head. You could for example use that same empty to focus the camera on his face, or place a hat on his head, or make a projective hit his head or make a projectile start from his head. etc etc. The uses for an empty called “Head” that would be always be positioned at the character head are many. So you might as well take advantage of that and add one more use for it by placing an arrow on it.

You are right, I came to that conclusion too.
Thank you for your help :slight_smile: