In general, an actor needs to be created with material exactly the same as material appeared in object of UInstancedStaticMeshComponent.
Instanced static mesh has multiple instances with material properties tweaked for every instance via PerInstanceCustomData. Few floats are passed as custom parameters to define how specific mesh instance should look like. So far so good. Now it is needed to “extract” color and other material properties of specific instance and apply those to different actor. Within approaches that I’ve tried (unsuccessfully) the questions can be formulated as:
How to acquire or generate material from specific mesh instance?
How to pass floats to PerInstanceCustomData into material to get desired looking material?
I don’t get an option to retrieve this data on a per instance value. You may have to keep it in a Map <int, parameter> where int would be the index of the instance and parameter be the passed variable type. Then set the TMap in parallel when adding the instance.
In c++ there is a TArray PerInstanceSMCustomData that maybe can be accessible (would have to dive into the docs to see it’s visibility)
Update: Yes it does seem to be accessible from c++ though it’s seems to be a little cumbersome having to pass in an index then multiplying the this by the NumCustomDataFloats to get the correct variables.
Thanks for reply. And sorry for possible ill formulation of the question.
Right, custom data can be accessed. From c++, for any instance. I get stumbled on how to apply these custom data to new material. New material is what needed to make a copy.
A copy of material is needed to make an actor, of different mesh, but of the same color (and all material properties).
Right. The next (unknown) part is how to make a material from custom data retrieved. An actor on which these custom data to be applied is NOT InstancedStaticMeshComponent. I could implement another material, or use existing with PerInstanceCustomData, but how to apply custom data, see my question 2. These PerInstanceCustomData seems to require instanced mesh, which is not what exists per se.
Again, from more general perspective. Suppose, there are 1000 instanced mesh “actors”, each having the same mesh but different positions, sizes and material properties, like color, emissivenes, etc. What I need is to replace one instanced mesh “actor” by another (completely different and true) actor. Say, there are one thousand goblins marching on battlefield. Merlin comes and converts one goblin into a dragon. This dragon should preserve parent-goblin’s color. How should it be done?