BGE proposal: Mouse Over Any sensor with Property and X-Ray

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


  • This would allow to limit the number of objects to be sensed by the MouseOverAny Sensor.
  • This would allow to ignore other objects.


  • 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).

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?)

That is indeed possible… yes this seems to be true and it makes sense as we can’t see any further :D.

The X-Ray Mode for Mouse-Over makes sense as well.

I committed a patch for this.

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.

HG1, this is pretty cool.

Huh, old Logic Brick with new options?
Champagne! :wink: