Setting Material and Material Instance In c++ Without Crashing
I'm in the process of converting some of my blueprints to code and I keep hitting this problem. Maybe I'm missing something obvious but it causes the engine to crash when the code should be changing the material.
this is what I'm trying to achieve
and this is the error i get from it
asked Feb 08 '17 at 04:18 PM in C++ Programming
I see a couple things that I would change in my code:
First, after doing FObjectFinder, you need to check if the search for the object succeeded. For example, if I was looking for ShaderMat, I'd do
Here is the full code that I used to set up a dynamic material instance on a static mesh in an actor class.
Doing this seemed to work perfectly on my end.
Let me know if that helps or if you need any clarification/explanation.
Have a great day!
answered Feb 08 '17 at 07:14 PM
Sean L ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here