playMaker

Author Topic: Particle System Emit  (Read 3432 times)

Geropellicer

  • Playmaker Newbie
  • *
  • Posts: 10
Particle System Emit
« on: December 22, 2017, 09:02:41 PM »
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: [Select]
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);
}
}
}
« Last Edit: December 22, 2017, 09:05:33 PM by Geropellicer »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Particle System Emit
« Reply #1 on: January 29, 2018, 06:49:27 AM »
Hi,

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

 Bye,

 Jean

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Particle System Emit
« Reply #2 on: January 31, 2018, 07:32:06 AM »
Great one, thanks!
Available for Playmaker work

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Particle System Emit
« Reply #3 on: February 16, 2018, 01:22:26 AM »
Hi,

 The action is now on the Ecosystem

 Bye,

 Jean