# Mesh Data Particles refuses to change colour in runtime

**URL:** <https://forums.unrealengine.com/t/mesh-data-particles-refuses-to-change-colour-in-runtime/426336>\
**Category:** Rendering\
**Tags:** particle-systems, unreal-engine, color, bug-report, question\
**Created:** [May 31, 2018, 6:56am UTC](https://forums.unrealengine.com/t/mesh-data-particles-refuses-to-change-colour-in-runtime/426336 "2018-05-31T06:56:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hubacek.jakub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hubacek.jakub](https://forums.unrealengine.com/u/hubacek.jakub)\
**Post date:** [May 31, 2018, 6:56am UTC](https://forums.unrealengine.com/t/mesh-data-particles-refuses-to-change-colour-in-runtime/426336/1 "2018-05-31T06:56:21Z")

</div>

Hi community.

In 4.17 version of UE4 we were using Mesh Data emitter for different particle systems and we were able to change colour this way:

- take particle system component
- get material from particle system component
- create material instance from this material
- change parameter of this new material instance
- set new material instance as material for particle system component

In 4.17 everything worked great and colour were changing for all type of particle emitters, BUT in 4.19 Mesh Data emitter stopped to accept this change in runtime.  
GPU sprites are fine, even Ribbon data emitter type behaves right.

Does anybody experienced this problem ? Is there a way how to force particle system component to somehow reload materials that is using ?

Any advice is very welcome 🙂

---

<div class="post-metadata">

**Author:** ![Jeff\_A](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jeff\_A](https://forums.unrealengine.com/u/Jeff_A)\
**Post date:** [May 31, 2018, 5:12pm UTC](https://forums.unrealengine.com/t/mesh-data-particles-refuses-to-change-colour-in-runtime/426336/2 "2018-05-31T17:12:49Z")

</div>

Hello,

We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.

[https://epicsupport.force.com/unrealengine/s/](https://epicsupport.force.com/unrealengine/s/)

Thanks

---

<div class="post-metadata">

**Author:** ![hubacek.jakub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hubacek.jakub](https://forums.unrealengine.com/u/hubacek.jakub)\
**Post date:** [June 1, 2018, 7:11am UTC](https://forums.unrealengine.com/t/mesh-data-particles-refuses-to-change-colour-in-runtime/426336/3 "2018-06-01T07:11:28Z")

</div>

Submitted, thank you for pointing me out. I started this thread in hope that somebody find a way to bypass this problem 🙂

Thanks

---

<div class="post-metadata">

**Author:** ![hubacek.jakub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hubacek.jakub](https://forums.unrealengine.com/u/hubacek.jakub)\
**Post date:** [June 5, 2018, 8:59am UTC](https://forums.unrealengine.com/t/mesh-data-particles-refuses-to-change-colour-in-runtime/426336/4 "2018-06-05T08:59:50Z")

</div>

For anyone who hit this same issue as me.

Official issue can be tracked here: [Unreal Engine Issues and Bug Tracker (UE-59923)](https://issues.unrealengine.com/issue/UE-59923)

If this is something you really need and issue is not fixed I have solution for you.

Open Engine\Source\Runtime\Engine\Private\Particles\ParticleEmitterInstances.cpp

and use this

```
void FParticleMeshEmitterInstance::Tick_MaterialOverrides(int32 EmitterIndex)
{
	// we need to do this here, since CurrentMaterials is unique to mesh emitters, so this can't be done from the component. CurrentMaterials 
	// may end up in MeshMaterials, so if this doesn't get updated, rendering may access a garbage collected material

	// make sure currentmaterials are all set to the emitter material, so we don't end up with GC'd material pointers
	// in MeshMaterials when GetMeshMaterials pushes CurrentMaterials to MeshMaterials
	if (Component && Component->EmitterMaterials.IsValidIndex(EmitterIndex))
	{
		if (Component->EmitterMaterials[EmitterIndex])
		{
			//HACK(JAKUB.HUBACEK): HACK STARTS HERE
			//NOTE(jakub.hubacek): FParticleMeshEmitterInstance partially takes in account that mesh could have more than 1 material, but then it fails to take takes default material from array of current materials 
			if (Component->EmitterMaterials[EmitterIndex])
			{
				CurrentMaterial = Component->EmitterMaterials[EmitterIndex];
			}
			//HACK(JAKUB.HUBACEK): HACK ENDS HERE

			for (UMaterialInterface *& CurMat : CurrentMaterials)
			{
				CurMat = Component->EmitterMaterials[EmitterIndex];
			}			
		}
	}	
... function continues here

```

where my change is within

> //HACK(JAKUB.HUBACEK):  
> area

* * *

Have a nice day

Jakub

---

<div class="post-metadata">

**Author:** ![CodeSpartan](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/codespartan/32/1194561_2.png) [@CodeSpartan](https://forums.unrealengine.com/u/CodeSpartan)\
**Post date:** [June 21, 2018, 5:45pm UTC](https://forums.unrealengine.com/t/mesh-data-particles-refuses-to-change-colour-in-runtime/426336/5 "2018-06-21T17:45:43Z")

</div>

Lifesaving solution. Thank you.

---

<div class="post-metadata">

**Author:** ![nooSens](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nooSens](https://forums.unrealengine.com/u/nooSens)\
**Post date:** [December 4, 2018, 11:56am UTC](https://forums.unrealengine.com/t/mesh-data-particles-refuses-to-change-colour-in-runtime/426336/6 "2018-12-04T11:56:05Z")

</div>

Hi! Did you test this solution on 4.21? I added the code as indicated but with no change ingame. The mesh particles are still not being updated with the dynamic instance applied to the emitter.

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/0/0/70063be4862d379c3217303ff0efbff78a4e6ca8.png)
