Announcement

Collapse
No announcement yet.

Programmatically spawn particles?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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:

    Code:
    	TSubclassOf<class UParticleSystem> Particle;
    	UParticleSystem* ParticleSystem;
    In the constructor:

    Code:
    	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:

    Code:
    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.
    Last edited by rcapote; 11-19-2014, 03:54 PM.
Working...
X