XRay in BGE!

How do I make an object xray in bge?

Thanks in advance

As far as I know you need to give your object a property say ‘noray’ then in the ray sensor you need to set xray and add the property ‘noray’ in the property field.

So the ray goes just through your object with this property assigned.

Hope that helps

I just did what you said. The sensor is working but X-Ray button is doing nothing. Whether it is on or not, nothing is happening.
Now I am confused. See through means - does it mean the object will be visible through another object which does not have that property by “our eye” or the object will see through the object, mean it won’t detect that another object?

Thanks for reply

Say if you have a player with an xray sensor, then the player sees through the objects with the property assigned. But in fact the object is still visible in your eye.

@BirdaoGwra - I think you need to be clearer on what you want. If you want to be able to see an object through another one, you’ll need to use Overlay scenes and sync up the object’s positions and orientations.

Ya, actually when I posted this thread I did not realize that xray can make double meaning. Sorry for that.
I just want the object to be X-Rayed like the option in Object tab -> Display -> X-Ray mode. Always see through other objects.
As strub already said, the xray button in ray sensors should do it. But it did not. Thats why I got confused.

Thanks for the reply

Using Z Offset in materials will do what you want.


That is what it is actually called - disable/enable zdepth.
Thanks excalaberr.


For anyone wondering nowadays, you need to enable transparency on both objects, and on the object you intend to keep in front you need to enable “Invert Z Depth”.

Another option is to add a object in a overlay scene and sync the camera pos / rot in the overlay

You also need to set a z-depth value higher than zero. A negative value of zero still leaves the default value of zero as it originally was. ^^