OK, I’m not even sure that given the blueprint I have created that I can create a dynamic material instance. All of the examples I have seen show that a mesh needs to be set up in the Construction Graph. Since I don’t have anything to construct when the game starts, I don’t think I can use the Construction Graph because I can’t spawn a mesh in there.
This is the BP_LaserCreator:
Now I can put a Set Material function in between SpawnActor Static Mesh Actor and Set Cast Shadow, plug in Static Mesh Component, and make the laser any color I want. I could also put the Set Material function at the end, in between Set and Add, plug in LaserMesh (off of Set), and also set the laser color to anything I want. (I have done both of these successfully).
What I have not been able to figure out, is how to use Create Dynamic Material Instance instead of Set Material so that I can use a keyboard key event from the BP_ThirdPersonCharacter blueprint to change the laser color.
What I have tried to do (among dozens of other things), was to create BP_LaserMesh and spawn that in place of SpawnActor Static Mesh Actor so I could use use my mesh (SM_LaserMesh) in the Constuction Graph of BP_LaserMesh and hopefully be able to change the laser color dynamically.
In case you are wondering, I already have a material with parameters that I have applied to SM_LaserMesh, and have a test level where I put SM_LaserMesh in the BP_LaserMesh hierarchy and successfully change the mesh color from the BP_ThirdPersonCharacter blueprint with a keyboard key event.
So what I need help with is either implementing Create Dynamic Material Instance instead of Set Material or spawning BP_LaserMesh instead of SpawnActor Static Mesh Actor.
