blueprints not independent from each other?

I am changing a dynamic material in a skel mesh, there are multiple instances in the world with some having a material instance being applied (instance of another mat instance).

when i change the material in game with blueprints all the instances of the blueprint change (even intances of the mat instance).

what am i missing, and could you help me with the dynamic material instance to effect a single mesh only and not all meshes with the material applied ?

thanks

If you want each instance of the blueprint use it-own material params, you need to use DynamicMaterialInstances. However if you change the underlying Material from whcih those dynamic material instances are created, it will affect everything.

To simplify, Consider Materials as base classes and Material instances as Objects. When you change something in the base class, it will affect all instances of that class. Also if you assign a single instance of a class (an object) to multiple variables and change any property, it will affect all those variable (becuase they are all pointing to the same thing). But if you create multitple instances of a class and assing each to different variables, they all become independant. This is what you want to do.

So in a nutshell, to make each instance indpendent, use DynamicmaterialInstances. You can create them from blueprint (I usually create them in construction script or beginplay). In you construcion script, create a dynamic material instance from a base material and apply it to your mesh. If you change any params of this instance, it will not affect any other mesh.

Check out this one you can create Dynamic Material Instance in construction, then from that you can save that Instance then edit it in each blueprint differently, if you have some scalar or vector parameter exposed on material.

I already added and used the dynamic mat inst before posting, it still has issues though, ive posted images to show, i want each skel mesh to change independently from each other but when i “play” all skel meshes have the emmisive turned off? but i instanced a dynamic mat inst in construction ? so i dont know where ive gone wrong, (you can see the seperate mats in content browser), failhuman2,3,4 are instances of the instance failhuman1, would it be better to make them all instances of the original material?

the only thing i can think is that it is to do with the constuction script with the mesh then get mesh? but i put this in because the material can change because there are 4 variations of the pawn (via 4 inst materials)

![alt text][1]
alt text

dont think pics went up

more pics

3rd image is to set emmisive to zero at game start, then the 4th is to be part of gameplay

Try this:

  • Create a base material, which accepts material params to choose the emissive colors.
  • Within you character’s BP, create a dynamic material instance with the above material as the source. This dynamic material should be created in construction script and assigned to a variable for future access
  • After you have created the dynamic instance, set the material params for this instance to some value. I would create 3 public variables in the BP itself to store these values and edit them from properties window. This way you can configure the color from the default properties panel. In this case, I would simply use these 3 variables to set the material params
  • Later during gameplay, if you ever want to change material params, use the Material instance variable we created in step2 and manipulate it. It wont affect any other BP.

PS: Instead of using 3 separate scalar params, why don’t you pack them into a single Vector param? That way you only need to call 1 Set Material Param node

I dont think this works because I am trying to create 4 (at the moment 4) pawns (each with the same blueprint) but each has a different material, i have made these materials as instances of a master material, but on starting the game play they are all set to the material source I put in the construction blueprint, then when out of game play they switch back to the different respective materials I set them to!

this method would work if all the blueprints in the level were the same, and indeed only the pawn i am playing with ingame (as a test) emmisive lights change when I press the respective button, and the the other blueprints remain unchanged, its just on starting the game, the initial materials of all blueprint pawns change to the material on the pawn i am controlling.

If you don’t set the material params for an instance explicitly, they all end up using the default values you used in the original material, which makes them all identical.

Anyway, here is my construction script for an Actor BP with a static mesh and dynamic material instance. It works for me in 4.2 and 4.3

All I do is once I place an instance of this BP in the map, I edit the variables ColorR, ColorG, and ColorB to give all instances a different color. They all show up correctly in editor and during gameplay.

I think you are missing the step where you apply the dynamic material instance to the static mesh. Atleast I don’t see that in your screenshots

can i just ask, if you re-compile your blueprint with instances of the blueprint in the level are they all set to default colours ?

Nope. They stay the way I left them (as long as i dont change the type variable). When I said 'I set the values of the varibles Color R… I meant Iset them in the properties panel of the placed instance - NOT within the default properties panel in the blueprint editor. SO I place several instances of the Bp on the map. I select each of these instances and edit the variables values in the properties panel that show up on the right side.

Because BeginPlay is called on all instances of this BP when they are ready for the world. So if you set emissive to a hard-coded value (lets say 20), the same code is executed on all instances and they all get the same emissive value (20). But they are still independant, you just set them all to the same value.

On the other hand the key event is called only on the instance whcih you were controlling. So that event is not fired on other instances.

One way to see it in action is to set Emissive power to a random value from BeginPlay function. You can see that all instances get different emissive values this time.

Okay, thanks, I think I still need to look at it a bit more because of my added complexity, also I noticed that if I set emissive to zero in event begin play it effects all pawns, but if I do it with a key event after it only effects my controlled pawn ? Do you know why ?
Thanks

Thanks you’ve been really helpful :smiley: