Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Spawn emitter from particle system in assets?

I want to spawn an explosion at a location. I have the reference to the asset: ParticleSystem'/Game/Effects/ParticleSystems/Weapons/RocketLauncher/Impact/P_Launcher_IH.P_Launcher_IH'

How do I go about linking this asset to making it spawn in my game for a period of time without using Blueprints?

Product Version: UE 4.15
more ▼

asked Mar 14 '17 at 02:34 AM in C++ Programming

avatar image

1 2 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi Bob,

You can use the method in UGameplayStatics called SpawnEmitterAtLocation to spawn a particle system. There's plenty examples of other systems doing that in the code if you need more help.

more ▼

answered Mar 14 '17 at 02:08 PM

avatar image

1.6k 34 14 48

avatar image Bob21211111 Mar 14 '17 at 05:04 PM

I know about that method. All the other particle systems in code are in things like explosions, which are called after firing a grenade like weapon. I can't call the particle system directly. How do I create a new particle system in code and map an already created particle system in assets to it?

avatar image ExtraLifeMatt Mar 14 '17 at 05:47 PM

Hmm, I don't quite understand. What do you mean you can't call the particle system directly and want to map one particle system over another?

You might be able to use something like a Redirector, although that seems a bit scary. I'd just have it use whatever particle system you want instead. If you know the path of the asset you want to use, you can use FStringAssetReference with it's TryLoad() method to load the particle at runtime.

avatar image Bob21211111 Mar 14 '17 at 07:52 PM

I'm sorry I'll try to be as clear as possible.

I have this particle system declared in ShooterCharacter.h:

 /** effect played on respawn */
     UPROPERTY(EditDefaultsOnly, Category = Pawn)
     UParticleSystem* RespawnFX;

Right now it is called on respawn like this:

 if (RespawnFX)
 UGameplayStatics::SpawnEmitterAtLocation(this, RespawnFX, GetActorLocation(), GetActorRotation());

However it never executes inside the if statement. Am I right in assuming RespawnFX is somehow null? If so, does that mean a particle system is not properly attached to it? Also how would I go about attaching an effect to the particle system RespawnFX? Thank you.

avatar image ExtraLifeMatt Mar 14 '17 at 07:56 PM

Respawn FX is likely null if you aren't seeing anything. You can place a breakpoint and verify. Your code would require a designer or someone is setting that value in the Unreal Editor and then saving it.

What do you mean "attaching an effect"? Do you want to attach another particle to this one you are trying to spawn? Or do you want the RespawnFX attached to some object?

avatar image Bob21211111 Mar 14 '17 at 08:00 PM

I might be using the wrong terms as I am new to Unreal Engine. I want RespawnFX to be assigned the bazooka effect that I have in my assets. I hope that in doing this then RespawnFX would no longer be null and upon respawn a bazooka effect would play.

avatar image ExtraLifeMatt Mar 14 '17 at 08:06 PM

Ah, Gotcha. You need to set RespawnFX somehow. Normally you do that through the editor. I assume you have a ShooterCharacter somewhere in your level? Click on it, find the RespawnFX field, and point it to the Bazooka Particle System. Then save and run your game.

You could also force in it code by something like this: FStringAssetReference BazookaPath(TEXT("/Game/Effects/ParticleSystems/Weapons/RocketLauncher/Impact/P_Launcher_IH")); RespawnFX = Cast(BazookaPath.TryLoad());

avatar image Bob21211111 Mar 14 '17 at 09:36 PM

Thank you so much! Remapping it worked. I've done so much research on getting this to work.

avatar image ExtraLifeMatt Mar 14 '17 at 09:39 PM

Yay! Cheers!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question