Emit particles on key press- particle system code – Unity3D – C#

KeyboardParticleJosiahMunsey

Place this script on a particle system.
When you press the “a” key it will burst the number of particles specified ( default 80 ).
Set the “emission rate over time” to 0 on the particle system for most obvious results when you key press.

using UnityEngine;
using System.Collections;

public class Particle_Burst_Control_Keypress: MonoBehaviour
{
    public int particleBurst = 80;
    ParticleSystem ps;

    void Start()
    {
        ps = GetComponent();

    }

    void Update()
    {
        var em = ps.emission;

        if (Input.GetKeyDown(KeyCode.A))
        {

            ps.Emit(particleBurst);

        }
    }
}

// easy unity code by Josiah Munsey 26PM

Leave a comment