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"

How do I reference my particle system in code?

In the tutorial for Variables, timers and, events near the end, you are shown how to create a particle emitter via Blueprint. I was curious about how to achieve this through code as opposed to Blueprints. I have checked out the Particle systems documentation but am unsure of how to reference the starter content "P_Explosion" in my code. Any direction would be much appreciated.

Product Version: UE 4.7
more ▼

asked Nov 02 '15 at 08:12 PM in C++ Programming

avatar image

135 19 28 36

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

1 answer: sort voted first


Direct references to assets in C++ code should be avoided. It's better to declare particle system component in your header file like this:

 class UParticleSystemComponent* PSC;

Then create it in your constructor:

 PSC = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("MyPSC"));

And then set it's template in editor.

If you still need a reference to particle system, you can get it like this:

 static ConstructorHelpers::FObjectFinder<UParticleSystem> PS(TEXT("ParticleSystem'/Game/StarterContent/Particles/P_Explosion.P_Explosion'"));
 PSC = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("MyPSC"));

Hope this helps.

more ▼

answered Nov 03 '15 at 04:49 PM

avatar image

Artem Gergel'
250 19 3 20

avatar image LostScout Nov 03 '15 at 09:22 PM

Thanks, that answered it.

avatar image K6L2 Mar 05 '18 at 12:10 AM

Hey Epic Games, you know what would be great? If when someone like me goes to your documentation for the particle system component I see these code snips at the top of the page. You guys should take a look at the documentation for SFML, it's so much better...

avatar image GameAboutThings Jun 27 '18 at 02:25 PM

For some reason I get an EXCEPTION_ACCESS_VIOLATION on the line of the FObjectFinder. Any idea how this could happen?

(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