Material Color set in C++ class but not in blueprint class
I'm currently working on a small game idea that involves shooting projectiles that change color when they hit a wall.
I'm doing this project in C++, but created a blueprint instance to have more control over the meshes and all and i discovered something weird: If my character spawns the C++ class projectile, it successfully changes color, but if i instead spawn the blueprint that inherits from that class, it won't change color!
I don't know why this happens so I'm reporting it as a bug...
This is the code on my projectile C++ class constructor:
This is the code that i use to spawn the C++ version of the class (that successfully changes color):
This is the code i use to spawn the blueprint version of the class (which does not change color at all, i'm using the base material and its color remains white, screenshot in the next comment):
Can someone explain to me what's going on?
I was not able to use your class directly due to references to project specific code, however I did manage to setup a sample case that works:
I first created a "projectile color" material with a base color parameter. Then in my projectile class, I added an FLinearColor variable as well as a UMaterialInstanceDynamic and UMaterial pointer. In the constructor of my projectile class, I used a ConstructorHelper to get a reference to the material and set that to my UMaterial pointer.
I then used my static mesh component to set my material instance dynamic pointer.
On tick, I find a random number for the R, G, B, and A values of my FLinearColor
In My hit function I can then use the material instance dynamice pointer to set the parameter value of the Material
answered Aug 01 '16 at 07:58 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here