Crate bevy_particle_systems

Source
Expand description

A particle system plugin for bevy

Currently sprite based and focused on 2D.

§Usage

  1. Add the ParticleSystemPlugin plugin.
use bevy::prelude::*;
use bevy_particle_systems::ParticleSystemPlugin;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(ParticleSystemPlugin::default()) // <-- Add the plugin
        // ...
        .add_systems(Startup, spawn_particle_system)
        .run();
}

fn spawn_particle_system() { /* ... */ }
  1. Spawn a particle system whenever necessary.

fn spawn_particle_system(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands
    // Add the bundle specifying the particle system itself.
    .spawn(ParticleSystemBundle {
        particle_system: ParticleSystem {
            max_particles: 10_000,
            texture: ParticleTexture::Sprite(asset_server.load("px.png")),
            spawn_rate_per_second: 25.0.into(),
            initial_speed: JitteredValue::jittered(3.0, -1.0..1.0),
            lifetime: JitteredValue::jittered(8.0, -2.0..2.0),
            color: ColorOverTime::Gradient(Curve::new(vec![
                CurvePoint::new(Color::WHITE, 0.0),
                CurvePoint::new(Color::srgba(0.0, 0.0, 1.0, 0.0), 1.0),
            ])),
            looping: true,
            system_duration_seconds: 10.0,
            ..ParticleSystem::default()
        },
        ..ParticleSystemBundle::default()
    })
    // Add the playing component so it starts playing. This can be added later as well.
    .insert(Playing);
}

Re-exports§

pub use components::*;
pub use values::*;

Modules§

components
Defines bevy Components used by the particle system.
values
Different value types and controls used in particle systems.

Structs§

ParticleSystemPlugin
The plugin component to be added to allow particle systems to run.
ParticleSystemSet
System label attached to the SystemSet provided in this plugin