Crash when change Parent Material

Hi. I wrote utility, which replaces parent material for all materials on object, but if this object already loaded in scene than on node “set material instance parent” unreal gets crash every time and closes.
It works fine if i make it on asset’s level. But if some actor, with this material loaded, I had the crash too.
Sorry for my language. I hope I described correctly

1 Like

Hello, sorry for necroing.

I just started learning Unreal and I don’t know enough to write a utility to replace the parent material for all instances on my object. Can’t find any tutorials on the subject.

If you managed to create it, any tips are greatly appreciated. Thank you!

1 Like

Hi, is there a legitimate reason to replace the parent? On the face of it it just seem to me that the processing you need is just too much if there are several materials being reparented at a time.
What are the capabilities of the second master that you need? I would go by making a robust master and have instances of it that meet the needs of the switch

Thanks for replying. My problem is the following, perhaps there is another way:

I have imported a static mesh (a spaceship) with 50 material instances with different textures. The instances have the same master material as parent.
Now, SOME of the instances (about 30) have to be metallic (the exterior of the ship), and the other 20 have to be non-metallic (some of the interior).
I am trying to see if I can make 30 instances metallic at once, without manually opening each of them and changing the metallic parameter.

I thought about using a Material Parameter Collection, but it affects the ENTIRE parent material (meaning, all 50 instances, which doesn’t help).
So I thought I would change the parent of the 30 instances (at once with a utility) and use the Material Parameter Collection only to the second parent, thus affecting only the 30 instances.

This seems like a lot of work for something that should (?) be way simpler…

Thats the best approach it seems. but reparenting in batch is not possible as far as I know. you’d need to reparent the 30 instances one by one, unless there have been some updates regarding this, in ue5.
This needs to be done prior to the asset being in the scene, as if it is done ‘live’ it seems to be too heavy of a task, and breaks the engine.

hey, did u also find solution for this? My editor is also crashing: even though I just worked on one material.

For anybody else like me who runs into this crash after calling set_material_instance_parent in Python or Blueprint, the solution is that you need to also call update_material_instance afterward to ensure the render state and proxies are updated/recreated.

1 Like

solved this error - firstly I set material instance parent into "None " value -(to dump the buffer) and then set material parent. For me, “update material instance” node also did not worked well :frowning:

Find my own solution here,
Removed any actors that reference this material instance, then update it’s parent, then engine won’t crash.

we should also use the Update Material Instance node.

1 Like

here’s what i do: for someone who bump into the same problem.

3 Likes

Yup, I just had to ‘update material instances’ and it no longer crashes. Thank you!