Also could you explain the meaning of all arguments of this function? I understand the meaning of Location and Rotation, AutoDestroy, but WorldContextObject, PoolingMethod and AutoActivateSystem(a little bit) are incomprehensible to me
You want a world location. Typically you want the world location of the impact point where the explosion hit (you may get this from collision testing/handling) but, worst case, just use the actor world location of the exploding actor.
PoolingMethod has to do with if you have tons of explosions, and want them to re-use rendering resources (and limit the max number going at the same time.)
AutoActivateSystem means it will start playing right away, you don’t have to separately call Activate on it to make it start emitting particles and animate.
WorldContextObject is the object that tells this system which world to spawn into. 99.9999% of the time, you’ll want to use the object that’s exploding, or if that’s already gone, use perhaps the player(controller) viewing the explosion.
Also, you’re giving a UParticleSystemComponent into the SpawnEmitterAtLocation’s EmitterTemplate argument. That’s wrong – you need to give it a UParticleSystem. SpawnEmitterAtLocation makes the new component automatically, so you can remove the DestroyParticleSystem component is the only place you are using it. To store the emitter template, in your header file, you’ll want to add a UParticleSystem variable, and set that to ParticleAsset.Object in the constructor. Then pass it in to the SpawnEmitterAtLocation function.
Thanks for the explanation. Now it became much clearer to me
As I don’t understand how to use my Actor as a UObject class (maybe I should use cast, but it’s not gonna work), I decided to use this overriden version:
An AActor is a UObject. So if you just pass in this as the argument, it will work. No casting required.
Also, this->GetWorld() can be substituted with GetWorld() and this->GetTransform() can be substituted with just GetTransform(). You only need this when you want a reference to the current object.
Just pass in “EPSCPoolMethod::YourEnumChoice” as the argument.