Distance-Based Alpha Texture Visibility in UPBGE 0.2.5

Hello, Everyone!

I know that it is possible to assign and IPO (action) keyframe to alpha textures in the Z transparency field of a material to adjust it’s alpha value (to make it more or less transparent). I have not had much success with it working in the game engine running off of logic bricks, but here’s my big question:
Is it possible to change the transparency of a texture (or material) depending on it’s proximity to an object? For example, if you have a cloud texture that’s on a 2D plane, you can slowly fade that texture the closer the player gets to it to give the illusion of flying through said cloud. Thank you for your help!

Hello,
Here is a demo example of camera-distance based material alpha transparency.
To preview this cool method, just exit out of the active camera view and in the default 3D view-port camera view, zoom in/out towards the blue cube and you should see the transparency of the object change.
I understand this isn’t exactly “proximity” distance checking, but it should be easy enough to modify the node set-up to get your desired function.

Credits to @Thomas_Murphy and Rudolph (I forget your BA account name) for the help of setting-up this demo.
Distance Based Alpha.blend (94.0 KB)

3 Likes

@RandomPerson >> You sir, are the man… Thanks for the quick response! I’ll give this a look.

Thank you!

Happy to help. Always watching from the shadows.0,…,o

2 Likes