Download

C++ Particle System - How to change particle system/emitter values in game?

Hi, I’m trying to write C++ code to change my particle system emitter values on the fly. For example, I want to change the spawn rate (100 -> 5) of the PS while the game is playing. I’ve looked at other articles and have been able to get a reference to my particle system and whatever I change in the actual PS editor, changes on screen (although, It’s having problems saving what I change). I’ve looked at the UParticleSystemComponent API and to no help. I have the ParticleSystemComponent.h in my includes as well so I know it works. Any help would be greatly appreciated!


static ConstructorHelpers::FObjectFinder<UParticleSystem> PS(TEXT("'/Game/My_Test_PS'"));
PSC = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("MyPSC"));
PSC->SetTemplate(PS.Object);


Hi There,

Literally I was having the same issue and looked around forever. Here is the solution I found.

so in my header file I declared the UParticleSystem object.


UPROPERTY(EditDefaultsOnly, Category = "Particle Effects")
UParticleSystem* BloodSplatter;

In my cpp file at the top…


#include "Particles/ParticleSystem.h"

Then in my constructor for the projectile…


static ConstructorHelpers::FObjectFinder<UParticleSystem> BloodSplatterObject(TEXT("ParticleSystem'/Game/WeaponEffects/BloodImpact/P_blood_splash_02.P_blood_splash_02'")); if (BloodSplatterObject.Succeeded())
  {
  [INDENT=2]BloodSplatter = BloodSplatterObject.Object;[/INDENT]
  }