The title is a little misleading, as what I really want is to detect only the part of the object the mouse is over. So, I might have a slanted plane, and want to pass a mouse along it. As the mouse passes over it, some script would determine the Z-Coord of just that part of the plane the mouse is currently over. If this were output to a property printed in Debug, you might see “testob.z-coord” start at 0 and count up (and down) as the mouse passed over the plane, detecting just the part of the object that the mouse is over.
I’m pretty sure I restated the same thing 2 or 3 times there. But you get the idea.
The purpose of this script is to place building objects on-mouse-click along a ground model like you see in games like Dawn of War or Star Craft.
SOLVED - credit to SolarLune
I use a cube (arbitrary name) with a Float Property “Z”. Then a Mouse Over Any sensor (named MouseOverAny) with True-Level-Triggering, tied to your python script. The script is as follows:
from bge import logic
cont = logic.getCurrentController()
own = cont.owner
mouseoverany = cont.sensors[“MouseOverAny”]
own[‘Z’] = mouseoverany.hitPosition.z