Mouse Over with X-Ray

Plantperson asked me some time ago how one could use the Mouse Over sensor in a third person game without having the character bounding box interfere with the mouse’s ability to detect objects.

This would be a relatively simple task were there an X-Ray button on the Mouse Over sensors as there is on the Ray sensor. However, such a button does not exist, so a workaround is required. I have come up with some ridiculously complex workarounds for it in the past, none of which were worth sharing here, but this one is pretty much the next best thing to having an X-ray button, so I thought I’d share it.

Sadly, my life is ridiculously busy these days, and I cannot spare the time to write a proper tutorial. If you can read Logic and Python, you should be able to figure it out, but here is a quick explanation:

  • Use the Mouse Over Any sensor to get the start and end points of the ray which is used by the mouse sensors to detect any object under the mouse.
  • Set the position of a second ray to the start point of the mouse ray, and cause it to track to the end point of the mouse ray. X-ray is enabled on this second ray, and the ray will only see objects with the property “mouse”.
  • Finally, a script gets the name of the hit object and displays it in the debug properties.

You will see in the attached file that the mouse does not register the tall central object, but it does see all other objects (the walls, floor, and cubes).

Attachments

mouseXRay.blend (39.3 KB)

Wonderful! Exactly what I needed! I owe you one!

Hi, I wanted to ask, if you download this file blend, you uploaded, it’s free, no charge, no virus?