PlayMaker Updates & Downloads > Share New Actions

Particle System Emit

(1/1)

Geropellicer:
Hi, I don't know if I didn't search properly or what, but I could't find an action to emit a certain amount of particles once or every frame, so I made one. Not sure if is the best approach since I've started writing my own actions very recently. Anyways it is working fine for me.


--- Code: ---using UnityEngine;
using System.Collections;
using System.Collections.Generic;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Character)]
[Tooltip("Emits a given number of particle from a Particles System. NOTE: You need to set the emit of this particle system to 0 at the editor, so it will not emit at all during play-mode by itself")]
public class ParticleSystemEmit : FsmStateAction
{
[RequiredField]
[Tooltip("The GameObject with the particleSystem to play.")]
[CheckForComponent(typeof(ParticleSystem))]
public FsmOwnerDefault gameObject;

[RequiredField]
[UIHint(UIHint.Variable)]
public FsmInt cantParticulas;

public bool everyFrame;

GameObject previousGo;
ParticleSystem _ps;

public override void Reset()
{
gameObject = null;
cantParticulas = 0;
everyFrame = false;
}

public override void OnEnter()
{
emitirParticulas();
if (!everyFrame) Finish();
}

public override void OnUpdate()
{
emitirParticulas();
}


public void emitirParticulas()
{
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
_ps = go.GetComponent<ParticleSystem>();
if (_ps == null) return;

if (go != previousGo)
{
previousGo = go;
}
_ps.Emit (cantParticulas.Value);
}
}
}

--- End code ---

jeanfabre:
Hi,

 uhm, indeed I think I need to add this to the mix on the Ecosystem thanks for contributing!

 Bye,

 Jean

Fat Pug Studio:
Great one, thanks!

jeanfabre:
Hi,

 The action is now on the Ecosystem

 Bye,

 Jean

Navigation

[0] Message Index

Go to full version