Download

Programmatically spawn particles?

I’m trying to spawn particles in C++, but it’s not working. No crashes or errors, just simply the particles don’t spawn.

In the header:



	TSubclassOf<class UParticleSystem> Particle;
	UParticleSystem* ParticleSystem;


In the constructor:



	static ConstructorHelpers::FObjectFinder<UParticleSystem> ParticleSystemClass(TEXT("/Game/StarterContent/Particles/P_Smoke"));
	Particle = (UClass*)ParticleSystemClass.Object->GetClass();
	ParticleSystem = Cast<UParticleSystem>(StaticConstructObject(Particle));


And when I try to spawn the particles:



UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ParticleSystem, GetActorLocation(), FRotator::ZeroRotator, true);


EDIT: Looks like what I had to do was set the particle effect in the editor, instead of trying to get and instance it in code.