# Creating Dynamic Material in Construct Script crashes engine at reload

**URL:** <https://forums.unrealengine.com/t/creating-dynamic-material-in-construct-script-crashes-engine-at-reload/376988>\
**Category:** Rendering\
**Tags:** unreal-engine, crash, construction-script, question\
**Created:** [November 21, 2016, 10:46am UTC](https://forums.unrealengine.com/t/creating-dynamic-material-in-construct-script-crashes-engine-at-reload/376988 "2016-11-21T10:46:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gaidline](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gaidline/32/754668_2.png) [@Gaidline](https://forums.unrealengine.com/u/Gaidline)\
**Post date:** [November 21, 2016, 10:46am UTC](https://forums.unrealengine.com/t/creating-dynamic-material-in-construct-script-crashes-engine-at-reload/376988/1 "2016-11-21T10:46:34Z")

</div>

I cannot create Dynamic Material Instance for Text Render Component in my Actor’s Construction Script because it crashes engine when I try to reload the level with the Actor inside.  
I can load the level properly for the first time, but engine crashes every time when I want to open it again (via editor).

In [engine log][1] I found an error referring to Material Instance Dynamic for my Component.

Is it safe to create Dynamic Materials in Construction Script?

 ![115778-construct.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/f/9/bf96f01a18b20ca0b99d5ef4422209c02f67bf79.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e729f54e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e729f54e](https://forums.unrealengine.com/u/anonymous_user_e729f54e)\
**Post date:** [November 21, 2016, 4:08pm UTC](https://forums.unrealengine.com/t/creating-dynamic-material-in-construct-script-crashes-engine-at-reload/376988/2 "2016-11-21T16:08:00Z")

</div>

Hello Koralgoll,

I was able to reproduce this issue on our end. It appears that this is a known issue and that it has been submitted to the developers for further consideration. I have provided a link to the public tracker. Please feel free to use the link provided for future updates. Thank you for your time and information.

Link: [Unreal Engine Issues and Bug Tracker (UE-29640)](https://issues.unrealengine.com/issue/UE-29640)

Make it a great day

---

<div class="post-metadata">

**Author:** ![brugr9](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/brugr9/32/1043108_2.png) [@brugr9](https://forums.unrealengine.com/u/brugr9)\
**Post date:** [February 26, 2023, 5:49pm UTC](https://forums.unrealengine.com/t/creating-dynamic-material-in-construct-script-crashes-engine-at-reload/376988/3 "2023-02-26T17:49:27Z")

</div>

This is still an issue in BP.

If a material (e.g., DefaultTextMaterial) is assigned to an object material element and then, with “Construction Script” a dynamic material instance of _the same material_ (DefaultTextMaterial) is created and assigned to the mesh again, the editor crashes.

But I have found a solution: First use the default material, e.g., DefaultTextMaterial or BasicShapeMaterial in my case, then create a dynamic material instance of not the same material, e.g., MI\_MPR-COR in my case and assign it to the mesh (see figure).

 ![Screenshot 2023-02-26 191758](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/4/b/e4b286e2a5775075051f0557959a29980011f23f.png)

---

<div class="post-metadata">

**Author:** ![KennyTeo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@KennyTeo](https://forums.unrealengine.com/u/KennyTeo)\
**Post date:** [June 15, 2024, 12:13pm UTC](https://forums.unrealengine.com/t/creating-dynamic-material-in-construct-script-crashes-engine-at-reload/376988/4 "2024-06-15T12:13:22Z")

</div>

Heya

Just to check, did you solution work for you 100% of the time?

My issue is closer to this:

> [@Engine crashes when stop simulating while a dynamic material instance is being set to a sprite component](https://forums.unrealengine.com/t/engine-crashes-when-stop-simulating-while-a-dynamic-material-instance-is-being-set-to-a-sprite-component/1399441):
>
> Hello, I’m using UE 5.3.2 and I’m experiencing an issue in which if you stop simulating (press ESC), while set a parameter of a dynamic material instance in event tick (or in a timeline, or quick timer), the engine crashes, here is the log (with symbols installed): Assertion failed: Index\>=0 && Index\<NumBits [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Containers\BitArray.h] [Line: 1418] UnrealEditor\_Core!FOutputDeviceRedirector::Panic() [D:\build\++UE5\Sync\Engine\Source\Runtim…

Its pretty much a crash that is caused by Dynamic Material Instance, that happens when you ESC from the simulation.  
However, I could not find a solution yet, so I am trying your solution, even if the situation is slightly different.

Anyways, the solution did not help my situation so I was wondering if I am doing it right, of if the solution works at all. Any info will be helpful.
