Hi, i’m trying to create an array of particle system actors that i then can attach to the actor that created the particle systems but i’m having a bit of trouble in doing so. I also want the particle system to use a particle system that i have created in cascade.
I’m pretty unsure how i should go about in creating the particle systems as their own actors that also uses the particle system that is in my content folder. It would be really helpful if someone pointed me to an example that shows how you would do this.
You can save out several particle systems from Cascade, in the content browser and add them as a component to your blueprint, then call them by “getting” them from the component list.
Or…
You can use SpawnEmitterAttached, or SpawnEmitterAtLocation and then create a reference to the emitters you wish to choose.
Offhand I don’t have a specific example that does this currently, if I get some time later today I can experiment with it for you, in the meantime perhaps you can try the above?
Absolutely! I don’t have the editor open in front of me, you might have to experiment with which PS variable works for your setup.
I’ll give that a shot. But using SpawnEmitterAttached, can you save the reference to the created emitter into a variable and then use that reference to further alter the emitter?
So i tried using SpawnEmitterAttached and it works great, i managed to create the particle systems and then put them into a array, but i cant seem to call on any of it’s variables or functions.
UParticleSystemComponent* ParticleTemp;
ParticleTemp = UGameplayStatics::SpawnEmitterAttached
(TemplateSystem,
RootComponent,
NAME_None,
GetActorLocation(),
GetActorRotation(),
EAttachLocation::KeepWorldPosition,
false);
ParticleSystems.Add(ParticleTemp);
Thats the code i use to create the emitters, but i cant seem to ParticleTemp-> to change any variables, is this normal?
Sorry, I create particle variables in BP and don’t have a problem…I sent off a mail to one of our programmers to see if he can shed some more light on this for you.
Alright, let me know if you hear anything that might help. I’ll keep trying.
I’m not entirely clear on what you mean by changing variables or calling functions on ParticleTemp.
Typically my workflow for using particles from C++ is as follows:
In the header put an array of particle templates
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Effects)
TArray<UParticleSystem> ParticleTemplates;
I would then create a blueprint from that C++ base class, then edit the defaults. You can browse for the particle systems in the content browser and assign them to array entries in ParticleTemplates.
UParticleSystemComponent* ParticleTemp;
ParticleTemp = UGameplayStatics::SpawnEmitterAttached
(ParticleTemplates[0],
RootComponent,
NAME_None,
GetActorLocation(),
GetActorRotation(),
EAttachLocation::KeepWorldPosition,
false);
ParticleSystems.Add(ParticleTemp);
Note that UGameplayStatics::SpawnEmitterAttached automatically activates the particle system. If you wanted to control when it activates, you would call ConstructObject yourself like CreateParticleSystem does in GameplayStatics.cpp.
The only way I normally interact with the created ParticleSystem component is calling things like
ParticleTemp->SetColorParameter("TeamColor", FLinearColor::Red);
From what i can tell, what i have is somewhat similar to how you explained you worked with particle systems in c++. But when i type in “ParticleTemp->” i get no fall down menu that contains things like from your example “SetColorParameter”. I’m not at my computer at the moment so i cant test the way you set the template with an array today, but i’ll give it a shot tomorrow.
Sometimes Intellisense does not work properly, I’m sorry for that, but I place the blame with the vendor there. The good news is that not having the Intellisense drop down does not stop the compiler. When the drop down is empty, you will just have to look at the header in UE4\Engine\Source\Runtime\Engine\Classes\Particles\ParticleSystemComponent.h or the manual page https://docs.unrealengine.com/latest/INT/API/RuntimeModules/Engine/Particles/UParticleSystemComponent/index.html
Alright, i’ll give that a go tomorrow. Thanks!
I thought it might be useful to add that its pretty hard to control the UParticleSystem Emitter at times. I personally prefer the UParticleSystemComponent, because you can Activate and Deactivate it at any time that you please. Hope this has helped you a bit!
At some point recently lots of links stopped working for me. Try: