# How to set Dynamic material Instance in C++?

**URL:** <https://forums.unrealengine.com/t/how-to-set-dynamic-material-instance-in-c/551257>\
**Category:** C++\
**Tags:** UE4-20, unreal-engine, UE4, CPP, question\
**Created:** [May 7, 2022, 1:10pm UTC](https://forums.unrealengine.com/t/how-to-set-dynamic-material-instance-in-c/551257 "2022-05-07T13:10:59Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![c0r37py](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/c0r37py/32/559700_2.png) [@c0r37py](https://forums.unrealengine.com/u/c0r37py)\
**Post date:** [May 7, 2022, 3:05pm UTC](https://forums.unrealengine.com/t/how-to-set-dynamic-material-instance-in-c/551257/9 "2022-05-07T15:05:16Z")

</div>

> [@Setting Material and Material Instance In c++ Without Crashing](https://forums.unrealengine.com/t/setting-material-and-material-instance-in-c-without-crashing/384303):
>
> 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 [125411-temp.jpg] .cpp .h [125399-temp.jpg] and this is the error i get from it

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-set-dynamic-material-instance-in-c/551257)._
