Godot Version
4.3.beta3
Question
I have multiple MeshInstance3D scenes (a MeshInstance3D as root) where I want to set transparency on a surface of only specific of them. The MeshInstance3D Nodes have a shared mesh and the mesh a shared material. Now it seems like it only works if I change the transparency when I duplicate the mesh and its subresources (the Material) both explicitly and set the duplicates. If I only duplicate the Material and set the transparency all other meshes are affected too. But when I duplicate the mesh, the duplication is forwared to the editor also… that’s so weird. How can I do this ?
for c: Variant in n.get_children():
if c is MeshInstance3D:
var mat: StandardMaterial3D = c.get_meta("original_material")
if c.get_meta("grid_layer") != grid_layer:
var new_mesh = c.mesh.duplicate()
new_mesh.surface_set_material(0, mat.duplicate(true))
c.mesh = new_mesh
mat = c.mesh.surface_get_material(0)
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
mat.albedo_color = Color(1.0, 1.0, 1.0, 0.2)
elif c.mesh.surface_get_material(0) != mat:
c.mesh.surface_set_material(0, mat)