Question on double face material

Hello,

First of all, can someone remind me if it’s possible to have 2 different materials in the BGE for a same mesh face ?

In my game, the character is in 3th view and sometimes the wall are masking my character (when showing face A) or the wall is just transparent (when showing face B) .


So my solution is to duplicate the mesh, flip the normals, and make the face A (of my duplicated mesh) semi-transparent.

As you can see, i’m able to see my character from the roof. But if my character is on the roof, i would like to see her the same way (the roof would become semi-transparent too - even if it is seen from below)


So, What i would like to do :

  • avoid to have duplicate the mesh : can i have in the BGE a single mesh with 2 faces with different materials ? ( 1 full diffuse, the second semi-transparent)

  • be able to flip the materials whether it’s not masking my character ( so the full diffuse) or masking my character (so the semi-transparent)


Other idea : Maybe would it be possible to have a 2d filter melting to semi-transparent all the vertex between my camera and my character ? (the mesh of my character will be fully rendered ofc)

2 Likes

why not simply set alpha with a tiny script?

obj.color = [r,g,b,a]

where a is alpha. You might need to activate the object color setting in the materials tab if it doesnt work.

This way you don’t have to make new meshes or faces, just tweak the alpha of the object between the camera and the player.

hello,

yes, i use already this to color my targets but i forgot that alpha channel x) So, good idea. I tried it but i dont like it as - after splitting the building into parts according to materials - i get some parts which have mesh all around on the map (same material) and sometimes, there’s more than 1 part/material annoying my camera view.

Is there any trick which could make like an occluder box parented to the camera which make : the closer to the camera - the more the vertex becomes transparent ? (except the characters ofc)

Any other idea ? For the moment, im just making the camera trying to avoid walls with raycast… but its tricky sometimes

Just use a Geometry Node with Back-facing as a Factor…
Single Plane…without anything but an array modifier

Just select and duplicate the texture you want…and add to a mix node with the Geometry Node as the factor…you can see it is now a two-sided plane…both sides could be you transparent material and would be just how you describe what you want…and you can forget all the duplicating flipping and all that…

2 Likes

thx, i will really try to dive in all those things once i have some time