Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to write a new class that I can drag from actor classes window into the scene and it will spawn a specific particle effect. Its going to be a 'prop' that later will also contain a static mesh and a point light. Maybe some defined variables that can be changed in the properties window. So far, I have the static mesh working using this code:

class LightFixture extends StaticMeshActor;

defaultproperties
{
    Begin Object Class=StaticMeshComponent Name=myMesh
        bAllowApproximateOcclusion=TRUE
        bForceDirectLightMap=TRUE
        bUsePrecomputedShadows=TRUE
        StaticMesh=StaticMesh'props.Meshes.lamp'
    End Object

    Components.Add(myMesh)
}

now, I'd like to add a particle system (template?), and from what I'm learning, it's not as easy as adding the mesh. In a new class, I tried to add a particle effect this way:

class FireParticle extends EmitterPool
placeable;

var ParticleSystemComponent PSC;

defaultproperties
{
    Begin Object Class=ParticleSystemComponent Name=myEffect
        bAutoActivate=true
        Template=ParticleSystem'props.FX.fire'
    End Object

    ParticleSystemComponent=myEffect
    Components.Add(myEffect)
}

So that didn't work... I read somewhere that emitterpool was the way to spawn.. I am very new to scripting, if that isn't already obvious :)

thanks in advance, if anyone can help..

share|improve this question

2 Answers 2

The EmitterPool is a manager class that you can use to spawn temporary emitters. You would do this by calling WorldInfo.MyEmitterPool.SpawnEmitter(...). For permanent emitters, you just need a ParticleSystemComponent variable in your actor set up basically exactly like you're doing.

So the main problem is that EmitterPool is defined in such a way that you can't place it (or subclasses of it) within the editor. You need to make your FireParticle class derive directly from Actor. Secondly, you need to change ParticleSystemComponent=myEffect to PSC=myEffect, so you assign it to your variable. With those two changes, you should be good to go.

share|improve this answer

Create a class something like this:

class MyParticleActor extends Actor placeable;

var ParticleSystemComponent ThePausePSC;

simulated event PostBeginPlay(){
    super.PostBeginPlay();
    ActivateMyPSC();
}

simulated function ActivateMyPSC(){
    if(ThePausePSC != none){
        ThePausePSC.SetScale(20.f);
        ThePausePSC.CustomTimeDilation = 0.25f;
        ThePausePSC.ActivateSystem();
    }
}

simulated function DeactivateMyPSC(){
    if(ThePausePSC != none){
        ThePausePSC.DeactivateSystem();
    }
}

defaultproperties
{
    Begin Object Class=ParticleSystemComponent Name=ThePauseParticleEffectSystemComponent
        Template=ParticleSystem'Eagle.Effects.PE_RobotPause';
        bAutoActivate=false
        bOwnerNoSee=true
        Scale=10.f
        Translation=(X=0.f,Y=0.f,Z=0.f)
    End Object
    ThePausePSC=ThePauseParticleEffectSystemComponent
    Components.add(ThePauseParticleEffectSystemComponent)

    Begin Object Class=SpriteComponent Name=Sprite44
        Sprite=Texture2D'EditorResources.Crowd.T_Crowd_Destination'
        HiddenGame=true
        HiddenEditor=false
        AlwaysLoadOnClient=False
        AlwaysLoadOnServer=False
        SpriteCategoryName="GSD"
        Scale=1
    End Object
    Components.Add(Sprite44)
}

Then drag and place on level. Right click on actor in level and click create archtype.

Find arch type in content browser, position viewport to get a good view of the particle effect in action, and right click on the arch type in content browser and set thumbnail to active viewport. Now you can drag it from the content browser.

What Philip says is correct as well, pay attention when to use the emitter pool and when not to depending on your usage of the particle.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.