UParticleSystemComponent SetMaterial not working?

Hi! I am trying to make my particle system match the main material of my parent component. (Basically I have a particle effect of my entities falling to bits on death, and I want the material to match no matter what the entity is).
I have managed to cobble together some code which compiles fine, but the particle effect keeps the default material, rather than the material of the parent.

This is the code in question:

	if (DeathFX)
		UParticleSystemComponent* SpawnedFX = UGameplayStatics::SpawnEmitterAtLocation(this, DeathFX, GetActorLocation(), GetActorRotation());
		if (DynaMats[0])

I can confirm my array has the right reference to the parent actor’s material. I guess I am doing something wrong with how I am making my reference to the particle system in question perhaps? I’m a bit rusty.

Does the material have the “works with particles” flag set?
(For the right kind of particles – there’s cascade versus niagara, and particles vs ribbons, and perhaps some other options. I forget)

Thanks for the suggestion, I just figured out the issue.

I didn’t realize that the material index also is an array that starts at 0, not 1. I was applying the material to the second material slot, not the first. It works now!

1 Like