Can I change a mesh's opacity during runtime?


I have a mesh that has a handful of materials on it that I need to make transparent the more it reaches the center of the screen. What I want to know is if there’s a way I can, inside the pawn blueprint, take the mesh and edit the opacity during gameplay. I would like to avoid editing the material as it complicates other details, but I will look into it if 100% necessary.

Thank you in advance!

Transparent? Or Translucent? They work quite differently. If you just want certain parts to disappear, you can set your material to Masked and then set the Opacity mask according to a distance threshold.

If you want it to be translucent (partly transparent), then UE renders that in a completely different manner and may not do what you want. A better solution is probably going with a masked Opacity and using dithering.

See this video for that technique.

But you can try a translucent material if you like. These draw after all the opaque and masked materials. Lighting can be done, but I’ve not had much luck with it.

If you’re setting it transparent based on screen location, you should be able to do it completely within the material. If you want a BP to set it, then you’ll have to create a dynamic material in your BP, set it on the mesh and then set a parameter on the material to indicate that it should be masked or set the opacity itself.

If you provide more details, I could probably give you more info.

edit: You mentioned you didn’t want to edit the materials. Materials are what controls what gets drawn. The only alternative is setting the Visible flag on a StaticMeshComponent, but that turns it on or off completely.

1 Like

hi @VirtualFriend509

Im afraid @AlienRenders is correct, you will need to modify the material in some way to achieve this. Maybe consider making a duplicate material to test with. Then add in some opacity parameters. Then set the mesh at runtime to use a dynamic material based on the new one you made allowing you to adjust parameters at run time Ie Opacity.

Worked wonders, thank you.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.