Rotate an object along face normal in the bge I have an empty that is at the center of the screen, it move to whatever you point at. An explanation on how to do so can be found here.  

I am looking to have a plane or empty always face outwards of whatever object it is colliding with. If this can't be done with an empty, I would be fine with a plane.

Here's a picture of what I don't want: (like this but in-game)



Here's a picture of what I do want: (like this but in-game, used wireframe as you cannot see in textured) See the plane is rotated to match the cube's face.



I am basically looking for the empty/plane (preferably empty) to face the outside of whatever it is colliding with.
Set up the logic bricks as pictured above.

This script will move an object (the cone) to the location of ray.hitPosition and then rotate it to point along the ray.hitNormal using alignAxisToVect().
For this example, the cone is pointing along the positive z axis. If it was along a different axis, I would have to pass in the second parameter to alignAxisToVect().
import bge

cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()

ray = cont.sensors[&quot;Ray&quot;]
cone = scene.objects[&quot;Cone&quot;]

if ray.hitObject and cone is not ray.hitObject:
    cone.worldPosition = ray.hitPosition
    cone.alignAxisToVect(ray.hitNormal)

Example gif, showing the cone moving and rotating to match the underlying geometry in the game engine.

Blend File