Set material of variable static mesh

hi, does anyone know how I can set the material of variable static mesh at run time?

If you have a scene component (static Mesh) you can access the Set Material or create dynamic material instance but you can’t if it is a variable Static Mesh!

Can you please clarify what a “variable” static mesh is? Do you mean a StaticMeshComponent with mobility set to “Movable”? Or do you mean a StaticMesh object, with no component?

That’s technically incorrect. SceneComponents alone can’t set materials, that’s part of PrimitiveComponent.

For the scene component what you add to an actor etc… and variable when you add a new variable as a static mesh. here is a pic.

Thanks for responding.

OK, the component is a StaticMeshComponent, and that inherits from PrimitiveComponent, which is how you can change the material.

The variable is an object of the type StaticMesh, which is an asset that stores the data for a mesh. Because it is not a Component, It is not able to be spawned in a world. It can only be rendered by a StaticMeshComponent. You can change the default material of a StaticMesh asset in the Static Mesh Editor.

Hope this helps!