Guides VFX & Particles Add 2D Particle Effects

VFX & Particles 4 min read Updated Apr 2026

Add 2D Particle Effects

A particle system is a component that repeatedly creates many small visual particles.

Use it when one object should create a short-lived effect instead of placing many separate sprites by hand. Common examples are:

  • dust when a character lands
  • sparks when a projectile hits a wall
  • floating motes around a magic object
  • a burst when the player collects a coin
  • smoke from a torch or engine

Lenga's 2D particle system is designed for lightweight gameplay effects. It gives you a ParticleSystem component that can emit textured or untextured 2D particles, sort with the rest of the 2D renderers, and be controlled from PHP.

Add a Particle System in the Editor

Start with the full editor workflow:

  1. Select the GameObject that should create the effect.
  2. In the Inspector, choose Add Component.
  3. Open 2D.
  4. Open Rendering.
  5. Choose Particle System.

You can also create a new particle GameObject from the Scene menu:

  1. Choose GameObject.
  2. Open 2D Object.
  3. Choose Particle System.

That creates a new GameObject with a ParticleSystem component already attached.

When you select that GameObject in the Scene view, Lenga shows the emitter's origin, direction, and spread so you can aim the effect visually while you edit it.

Understand the Main Settings

Texture controls what each particle looks like.

If Texture is empty, Lenga draws simple circle particles. This is useful for quick sparks, dust, and roughing out effects. If you assign a texture, each particle uses that image instead.

Play On Awake controls whether the particle system starts automatically when the scene starts.

Turn it on for continuous effects like smoke or ambient motes. Turn it off for one-shot effects that you want to trigger from code, such as a pickup burst.

Looping controls whether the emitter keeps producing particles after it starts.

Turn it on for continuous effects. Turn it off when you only want particles that already exist to finish their lifetime.

Max Particles is the maximum number of particles this system can keep alive at once.

Higher values allow denser effects, but they cost more to update and draw. Start small, then increase it only when the effect visibly needs more particles.

Emission Rate is how many particles are created per second while the system is playing.

For example, 20 means the system tries to create about twenty particles every second.

Lifetime is how long each particle lives before disappearing.

A value of 0.5 means each particle lasts half a second. A value of 2.0 means each particle lasts two seconds.

Start Speed is how fast new particles move when they are spawned.

Start Size is how large each particle is when it is spawned.

Start Color is the color each particle starts with.

Gravity is an extra force applied to particles over time.

Use positive Y gravity if you want particles to fall downward in your 2D scene. Use negative Y gravity if you want particles to drift upward.

Emission Angle points the emitter in a direction.

Spread Angle controls how wide the emission cone is. A small spread creates a narrow spray. A spread of 360 sends particles in every direction.

Sorting Layer and Order In Layer decide whether the particles draw in front of or behind other 2D objects.

These work like other 2D renderers. Use them when particles need to appear behind the player, in front of the ground, or above UI-like world objects.

Trigger a Burst From Code

The code below belongs in a Behaviour class attached to a normal GameObject in your scene.

For example, you might create a GameObject called Pickup Effect, add a ParticleSystem component to it, then add this PickupEffectController Behaviour to the same GameObject.

<?php

namespace Platformer\Scripts\Effects;

use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\ParticleSystem;

final class PickupEffectController extends Behaviour
{
    private ?ParticleSystem $particles = null;

    public function start(): void
    {
        $this->particles = $this->getComponent(ParticleSystem::class);

        // Keep Play On Awake off in the Inspector when you want code to decide
        // exactly when the burst happens.
        $this->particles?->stop(true);
    }

    public function playPickupBurst(): void
    {
        $this->particles?->clear();
        $this->particles?->emit(24);
        $this->particles?->play();
    }
}

In this example:

  • getComponent(ParticleSystem::class) looks for the ParticleSystem on the same GameObject as the script.
  • stop(true) stops the emitter and clears existing particles.
  • emit(24) creates a burst of twenty-four particles immediately.
  • play() starts normal emission if the system is configured to keep emitting.

Change the Particle Texture From Code

You can also swap the particle texture from PHP.

Use a project-relative path, the same way you would when assigning assets elsewhere in gameplay code.

public function start(): void
{
    $particles = $this->getComponent(ParticleSystem::class);

    if ($particles !== null) {
        $particles->loadTexture('Assets/Sprites/Effects/dust.png');
        $particles->play();
    }
}

Where It Fits Best

This particle workflow covers focused 2D effects such as bursts, dust, sparks, smoke, and ambient particles.

If you want to see a shipped example, open the Platformer sample and look at the MainMenu scene. The torch objects there use looping particle emitters.