Issue:
The MouseOverAny Sensor casts a ray from somewhere near the cameras origin to a far away point (100BU) both under the system mouse cursor.
The issue is that the MouseOverAny Sensor does not allow to react on certain objects only (or ignore certain objects).
It is in some cases the MouseOverAny Sensor should only find special objects and measure through other.
My suggestion:
A) New Mode at the KX_MouseFocusSensor: MouseOverProperty
B) Enhance the MouseOverAny mode with more options
property: If set the ray reacts on objects with this property only (see Ray sensor)
X-Ray mode: If enabled the ray can cast through objects without the provided property
Benefits:
This would allow to limit the number of objects to be sensed by the MouseOverAny Sensor.
This would allow to ignore other objects.
Drawbacks:
Multiple Raycasts are needed to feed MouseOverAny sensors with different parameters. (This should not be a big deal as the current implementation casts a ray for each MouseOver(Any) sensor already).
Workaround:
Cast a ray via Python at each frame the MouseOverAnySensor is other another object.
This is very inefficient and should not be done at each frame.
Monster, I agree with you 100% that this is needed. I would like to see X-Ray and Property added to both MouseOver and MouseOverAny. I have needed this functionality in several large projects, and have had to use workarounds.
(I’m not sure how the endpoint of a mouse ray is currently determined, but shouldn’t it be the based on the End value of the Camera clipping?)
Here a screenshot from the modified “Mouse Over Any” sensor.
New sensor API:
sensor.useXRay = True # If enabled it allows the sensor to see through game objects that don't have the selected property or material.
sensor.propName = "prop" # The property or material the sensor is looking for.
sensor.useMaterial = True # Determines if the sensor is looking for a property or material.