Announcement

Collapse
No announcement yet.

referencing a UParticleSystemComponent in code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    referencing a UParticleSystemComponent in code

    Hi

    How does one reference a UParticleSystemComponent in code?

    When I try creating a property that would hold it:
    Code:
    UPROPERTY( VisibleDefaultsOnly, Category = Effects )
          TSubobjectPtr<UParticleSystemComponent>       ShotFX;

    and then initialize it in the constructor:
    Code:
    // particle system effect
    {
       ShotFX = PCIP.CreateDefaultSubobject<UParticleSystemComponent>( this, TEXT( "ShotFX" ) );
       ShotFX->AttachParent = ShotgunMesh;
    }
    I get a compile time error saying that the class is undefined:
    error C2027: use of undefined type 'UParticleSystemComponent'
    Any attempt to include its header tells me that the file is off limits.


    Cheers,
    Piotr

    #2
    Nevermind - found it.
    Although it's kind of weird that you get a StaticMeshComponent included out of the box, and in order to get a particle system component, you need to add these:

    Code:
    #include "ParticleHelper.h"
    #include "Particles/ParticleSystem.h"
    #include "Particles/ParticleSystemComponent.h"
    Cheers,
    Piotr

    Comment


      #3
      The same thing happens with UDecalComponent. I posted a question on answerhub about this. I wonder if this is by design or simply an oversight.
      Join us on IRC! We are on #unrealengine @ freenode.org

      Comment


        #4
        I would say that is a philosophy change that has emerged over time, particularly with the removal of UnrealScript.

        The problem with putting everything in Engine.h is that when you change something you have to recompile everything and your compile times get much worse. Ideally each cpp would include just the headers that it needs and it might improve compile times. Sometimes there are dependencies that must be grouped together which is where things like ParticleDefinitions.h and SoundDefinitions.h come from. And for the rest of it is a legacy issue, it takes a long time to clean up the reliance on the global header includes and we have to balance the time it would take and issues it would introduce for users of the engine when getting new versions against the benefits it will bring us.
        Last edited by Marc Audy; 04-10-2014, 02:01 PM.

        Comment


          #5
          MSDN handles this well: for each Win32 function or data structure, there's a note at the bottom telling you which header file it's actually defined in, and which header you want to include. It'd be nice to have that in the API docs for each class.

          Comment


            #6
            That would be quite nice, I agree. I found, that there are some Engine*Classes.h files that can be used. EngineDecalClasses.h for instance includes DecalActor and DecalComponent.
            Join us on IRC! We are on #unrealengine @ freenode.org

            Comment

            Working...
            X