You can add a object that is the sensor to get input from it next frame,
like
Sensor = bge.logic.getCurrentScene().addObject(‘Radar’,own,1)
Sensor[‘PropertySensorLooksFor’] = targetProperty
and have a brick marked first in the sensor object that applies the property to thr sensor, and then have a script attached to the sensor that sets the data in the script that called the sensor.
The mouse over sensor triggers the controller if something changed. This is pretty efficient. The sensor provides you with all information you can get from that event.
Here is a solution:
Use an always sensor that constantly triggers a Python controller.
The Python controller:
evaluates the mouse cursor position
transforms it into a ray from camera origin through this cursor position
when the ray hits something you get an hitObject
All of that is done by the Mouse over (any) sensor already … and it runs in native code.
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
MOA = cont.sensors['MouseOverAny']
if MOA.Positive:
own['Positive']=True
own['Target']=MOA.hitObject
else:
own['Positive']=False
own['Target']="Empty"
then other objects can lookup and store the mouse over sensor object, and grab data when it needs it?
if 'MouseOverObject' not in own:
own['MouseOverObject']=bge.logic.getCurrentScene().objects['MouseOverOb']
else:
MOO = own['MouseOverObject']
if MOO['Positive']==True:
own['Target']=MOO['Target']