Hi, I would like to ask how do I access dynamic material property of a material which is on multiple objects.
In my object/actor blueprint I can change it’s material(set material) or change dynamic instance parameter(with creating a dynamic instance) but this is only local change to one instance of the object.
But if I have a hundred chairs in a restaurant for example I want to be able to either set material on all of them by clicking just on any single one. Or change texture/color on a dynamic instanced material they all already have(which means I cannot use “create dynamic material instance” cause it will be aplied only on one object)
Can I cast to all instances of the object or can I change the dynamic material property they all have?
There are several solutions. Unfortunately you did not specify whether you need this run-time or editor only (tweaking values to get the right look), so I will post those that come to my mind instantly.
- Both cases: Make the chair a blueprint and change the default value in the blueprint that is applied in the material in construction script. Requires recompiling blueprint each change. In run-time, simply call the function that you used in construction script to set that in the first place.
- Run-time Only: GetAllActors of Class, iterate, set value on their dynamic instances. You will have access to those instances if you make these chairs blueprints. Will have to be done in level blueprint, which makes it a bit harder to maintain across several levels.
- Both cases (no need for blueprint): make the material use Material Parameter Collection. By changing a single value in the collection, all the actors using that variable will update. Chairs can be static meshes (cheaper and faster than BP) and it will work everywhere. Takes some setup, but as far as I understood your problem, that’s where I’d go. Very scalable.
There are also several other hacky ways, but since this can be done gently, why bother with hacks.
If you’d like, you can explain the issue in more detail, I’d answer and maybe hint something else.