Can I set an object to be always shown in front of another object?

I wonder if I can set an object or a material to be always in front or the back of particular other objects.
Is it possible?

If you’re using a legacy version of UPBGE or still using BGE, you can use the Z-Depth setting:

Note: Setting the Alpha Blend type to Alpha Sort can also help with the Z-Depth appearing correctly, even if you don’t use transparency.


I’m not aware of any method for UPBGE 0.3+ with the exception of using the In Front object setting.
Note: The setting only works in Solid Mode.
You can “technically” run a game while in solid mode by enabling the Use Viewport option, but that to be honest, is a fair poor substitute, not to mention it’s a very unstable, using viewport render.

You probably can’t tell, but I’m running BGE in the viewport at the time the screenshot is taken. You can verify this by noticing the scene camera is not active, because it’s using the default_cam camera.

1 Like

Thank you, this works great in BGE.
But I guess it’s not really what I was looking for.
This moves the object in front of everything.
I wanted to show the object only in front of certain another object.
Is that possible with a mask or something?

Technically yes, you can give render priority to an object with Scene Overlays (legacy) or Scene Collections (current). There are only physics masks in BGE/UPBGE but not render masks to my knowledge. Render masks require some very complex shader code.

You can make a “X-RAY” effect with material nodes however:

Not sure if this works in UPBGE 0.3+.

1 Like

Thank you, this is an interesting effect.
So it’s using a light source as a mask.
It’s not exactly what I need but it might be useful.