Struct bevy_particle_systems::components::ParticleSystem
source · pub struct ParticleSystem {Show 23 fields
pub max_particles: usize,
pub texture: ParticleTexture,
pub rescale_texture: Option<Vec2>,
pub spawn_rate_per_second: ValueOverTime,
pub emitter_shape: EmitterShape,
pub initial_speed: JitteredValue,
pub velocity_modifiers: Vec<VelocityModifier>,
pub lifetime: JitteredValue,
pub color: ColorOverTime,
pub initial_scale: JitteredValue,
pub scale: ValueOverTime,
pub initial_rotation: JitteredValue,
pub rotation_speed: JitteredValue,
pub rotate_to_movement_direction: bool,
pub looping: bool,
pub system_duration_seconds: f32,
pub max_distance: Option<f32>,
pub z_value_override: Option<JitteredValue>,
pub bursts: Vec<ParticleBurst>,
pub space: ParticleSpace,
pub use_scaled_time: bool,
pub despawn_on_finish: bool,
pub despawn_particles_with_system: bool,
}
Expand description
Defines the parameters of how a system and its particles behave.
A ParticleSystem
will emit particles until it reaches the system_duration_seconds
or forever if looping
is true, so long as the
entity with the ParticleSystem
also has a Playing
component.
If a ParticleSystem
component is removed before all particles have finished their lifetime, the associated particles will all despawn themselves
on the next frame.
Fields§
§max_particles: usize
The maximum number of particles the system can have alive at any given time.
texture: ParticleTexture
The texture used for each particle.
rescale_texture: Option<Vec2>
If provided, re-scale the texture size
This is simply passed directly to Sprite::custom_size
or TextureAtlasSprite::custom_size
spawn_rate_per_second: ValueOverTime
The number of particles to spawn per second.
This uses a ValueOverTime
so that the spawn rate can vary over the lifetime of the system.
emitter_shape: EmitterShape
The shape of the emitter.
initial_speed: JitteredValue
The initial movement speed of a particle.
This value can be constant, or have added jitter to have particles move at varying speeds.
velocity_modifiers: Vec<VelocityModifier>
Modifiers affecting the particle velocity.
They can be stacked, and will be applied in order.
No modifiers makes the particle move at its initial_speed
for its lifetime.
lifetime: JitteredValue
The lifetime of each particle, in seconds.
This value can have jitter, causing lifetimes to vary per particle.
color: ColorOverTime
The color of each particle over time.
Color is used to modify the default_sprite
. A constant value of bevy_render::prelude::Color::WHITE
will make the sprite appear with no modifications.
This can vary over time and be used to modify alpha as well.
initial_scale: JitteredValue
The initial scale of a particle.
This value can be constant, or have added jitter to have particles with different sizes
This value is multiplied with scale to produce the final scale.
scale: ValueOverTime
The scale or size of the particle over time.
Changing this value over time shrinks or grows the particle accordingly.
Multiplied with initial_scale
to produce the final scale.
initial_rotation: JitteredValue
The rotation of a particle around the z
access at spawn in radian.
rotation_speed: JitteredValue
The speed at which the particle rotates in radian per second.
rotate_to_movement_direction: bool
Rotates the particle to be facing the movement direction at spawn.
This is useful if the image used for the particle has a visual ‘forward’ that should match it’s movement, such as an arrow.
This rotation for the movement direction will be added to the initial_rotation
value,
to account for needing to apply a base rotation to the sprite.
looping: bool
Whether or not the system will start over automatically.
system_duration_seconds: f32
How long the system will emit particles for.
max_distance: Option<f32>
A maximum distance a particle can travel before being despawned.
z_value_override: Option<JitteredValue>
Set a fixed/constant z value (useful for 2D to set a fixed z-depth).
bursts: Vec<ParticleBurst>
A series of bursts of particles at configured times.
space: ParticleSpace
What coordinate space particles should use.
use_scaled_time: bool
Dictates whether this system respects Bevy’s time scaling by using bevy_time::Virtual
when true, or bevy_time::Real
when false.
despawn_on_finish: bool
Indicates that the entity the ParticleSystem
is on should be despawned when the system completes and has no more particles.
Defaults to false
.
Note that this will never trigger on a system that has looping
set to true
.
despawn_particles_with_system: bool
Indicates whether alive particles should be despawned when the system itself is despawned.
When this is false
(the default), particles will live out their lifetime even if the system has been despawned.
Implementations§
Trait Implementations§
source§impl Clone for ParticleSystem
impl Clone for ParticleSystem
source§fn clone(&self) -> ParticleSystem
fn clone(&self) -> ParticleSystem
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Component for ParticleSystem
impl Component for ParticleSystem
§type Storage = TableStorage
type Storage = TableStorage
TableStorage
or SparseStorage
.source§impl Debug for ParticleSystem
impl Debug for ParticleSystem
source§impl Default for ParticleSystem
impl Default for ParticleSystem
source§impl FromReflect for ParticleSystemwhere
Self: Any + Send + Sync,
usize: FromReflect + TypePath,
ParticleTexture: FromReflect + TypePath,
Option<Vec2>: FromReflect + TypePath,
ValueOverTime: FromReflect + TypePath,
EmitterShape: FromReflect + TypePath,
JitteredValue: FromReflect + TypePath,
Vec<VelocityModifier>: FromReflect + TypePath,
ColorOverTime: FromReflect + TypePath,
bool: FromReflect + TypePath,
f32: FromReflect + TypePath,
Option<f32>: FromReflect + TypePath,
Option<JitteredValue>: FromReflect + TypePath,
Vec<ParticleBurst>: FromReflect + TypePath,
ParticleSpace: FromReflect + TypePath,
impl FromReflect for ParticleSystemwhere
Self: Any + Send + Sync,
usize: FromReflect + TypePath,
ParticleTexture: FromReflect + TypePath,
Option<Vec2>: FromReflect + TypePath,
ValueOverTime: FromReflect + TypePath,
EmitterShape: FromReflect + TypePath,
JitteredValue: FromReflect + TypePath,
Vec<VelocityModifier>: FromReflect + TypePath,
ColorOverTime: FromReflect + TypePath,
bool: FromReflect + TypePath,
f32: FromReflect + TypePath,
Option<f32>: FromReflect + TypePath,
Option<JitteredValue>: FromReflect + TypePath,
Vec<ParticleBurst>: FromReflect + TypePath,
ParticleSpace: FromReflect + TypePath,
source§fn from_reflect(reflect: &dyn Reflect) -> Option<Self>
fn from_reflect(reflect: &dyn Reflect) -> Option<Self>
Self
from a reflected value.source§fn take_from_reflect(
reflect: Box<dyn Reflect>
) -> Result<Self, Box<dyn Reflect>>
fn take_from_reflect( reflect: Box<dyn Reflect> ) -> Result<Self, Box<dyn Reflect>>
Self
using,
constructing the value using from_reflect
if that fails. Read moresource§impl GetTypeRegistration for ParticleSystemwhere
Self: Any + Send + Sync,
usize: FromReflect + TypePath,
ParticleTexture: FromReflect + TypePath,
Option<Vec2>: FromReflect + TypePath,
ValueOverTime: FromReflect + TypePath,
EmitterShape: FromReflect + TypePath,
JitteredValue: FromReflect + TypePath,
Vec<VelocityModifier>: FromReflect + TypePath,
ColorOverTime: FromReflect + TypePath,
bool: FromReflect + TypePath,
f32: FromReflect + TypePath,
Option<f32>: FromReflect + TypePath,
Option<JitteredValue>: FromReflect + TypePath,
Vec<ParticleBurst>: FromReflect + TypePath,
ParticleSpace: FromReflect + TypePath,
impl GetTypeRegistration for ParticleSystemwhere
Self: Any + Send + Sync,
usize: FromReflect + TypePath,
ParticleTexture: FromReflect + TypePath,
Option<Vec2>: FromReflect + TypePath,
ValueOverTime: FromReflect + TypePath,
EmitterShape: FromReflect + TypePath,
JitteredValue: FromReflect + TypePath,
Vec<VelocityModifier>: FromReflect + TypePath,
ColorOverTime: FromReflect + TypePath,
bool: FromReflect + TypePath,
f32: FromReflect + TypePath,
Option<f32>: FromReflect + TypePath,
Option<JitteredValue>: FromReflect + TypePath,
Vec<ParticleBurst>: FromReflect + TypePath,
ParticleSpace: FromReflect + TypePath,
source§impl Reflect for ParticleSystemwhere
Self: Any + Send + Sync,
usize: FromReflect + TypePath,
ParticleTexture: FromReflect + TypePath,
Option<Vec2>: FromReflect + TypePath,
ValueOverTime: FromReflect + TypePath,
EmitterShape: FromReflect + TypePath,
JitteredValue: FromReflect + TypePath,
Vec<VelocityModifier>: FromReflect + TypePath,
ColorOverTime: FromReflect + TypePath,
bool: FromReflect + TypePath,
f32: FromReflect + TypePath,
Option<f32>: FromReflect + TypePath,
Option<JitteredValue>: FromReflect + TypePath,
Vec<ParticleBurst>: FromReflect + TypePath,
ParticleSpace: FromReflect + TypePath,
impl Reflect for ParticleSystemwhere
Self: Any + Send + Sync,
usize: FromReflect + TypePath,
ParticleTexture: FromReflect + TypePath,
Option<Vec2>: FromReflect + TypePath,
ValueOverTime: FromReflect + TypePath,
EmitterShape: FromReflect + TypePath,
JitteredValue: FromReflect + TypePath,
Vec<VelocityModifier>: FromReflect + TypePath,
ColorOverTime: FromReflect + TypePath,
bool: FromReflect + TypePath,
f32: FromReflect + TypePath,
Option<f32>: FromReflect + TypePath,
Option<JitteredValue>: FromReflect + TypePath,
Vec<ParticleBurst>: FromReflect + TypePath,
ParticleSpace: FromReflect + TypePath,
source§fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
&mut dyn Any
.source§fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>
fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>
source§fn as_reflect(&self) -> &dyn Reflect
fn as_reflect(&self) -> &dyn Reflect
source§fn as_reflect_mut(&mut self) -> &mut dyn Reflect
fn as_reflect_mut(&mut self) -> &mut dyn Reflect
source§fn clone_value(&self) -> Box<dyn Reflect>
fn clone_value(&self) -> Box<dyn Reflect>
Reflect
trait object. Read moresource§fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>
fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>
source§fn reflect_kind(&self) -> ReflectKind
fn reflect_kind(&self) -> ReflectKind
source§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
source§fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
source§fn reflect_owned(self: Box<Self>) -> ReflectOwned
fn reflect_owned(self: Box<Self>) -> ReflectOwned
source§fn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool>
fn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool>
source§fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
source§fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
source§fn serializable(&self) -> Option<Serializable<'_>>
fn serializable(&self) -> Option<Serializable<'_>>
source§fn is_dynamic(&self) -> bool
fn is_dynamic(&self) -> bool
source§impl Struct for ParticleSystemwhere
Self: Any + Send + Sync,
usize: FromReflect + TypePath,
ParticleTexture: FromReflect + TypePath,
Option<Vec2>: FromReflect + TypePath,
ValueOverTime: FromReflect + TypePath,
EmitterShape: FromReflect + TypePath,
JitteredValue: FromReflect + TypePath,
Vec<VelocityModifier>: FromReflect + TypePath,
ColorOverTime: FromReflect + TypePath,
bool: FromReflect + TypePath,
f32: FromReflect + TypePath,
Option<f32>: FromReflect + TypePath,
Option<JitteredValue>: FromReflect + TypePath,
Vec<ParticleBurst>: FromReflect + TypePath,
ParticleSpace: FromReflect + TypePath,
impl Struct for ParticleSystemwhere
Self: Any + Send + Sync,
usize: FromReflect + TypePath,
ParticleTexture: FromReflect + TypePath,
Option<Vec2>: FromReflect + TypePath,
ValueOverTime: FromReflect + TypePath,
EmitterShape: FromReflect + TypePath,
JitteredValue: FromReflect + TypePath,
Vec<VelocityModifier>: FromReflect + TypePath,
ColorOverTime: FromReflect + TypePath,
bool: FromReflect + TypePath,
f32: FromReflect + TypePath,
Option<f32>: FromReflect + TypePath,
Option<JitteredValue>: FromReflect + TypePath,
Vec<ParticleBurst>: FromReflect + TypePath,
ParticleSpace: FromReflect + TypePath,
source§fn field(&self, name: &str) -> Option<&dyn Reflect>
fn field(&self, name: &str) -> Option<&dyn Reflect>
name
as a &dyn Reflect
.source§fn field_mut(&mut self, name: &str) -> Option<&mut dyn Reflect>
fn field_mut(&mut self, name: &str) -> Option<&mut dyn Reflect>
name
as a
&mut dyn Reflect
.source§fn field_at(&self, index: usize) -> Option<&dyn Reflect>
fn field_at(&self, index: usize) -> Option<&dyn Reflect>
index
as a
&dyn Reflect
.source§fn field_at_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>
fn field_at_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>
index
as a &mut dyn Reflect
.source§fn name_at(&self, index: usize) -> Option<&str>
fn name_at(&self, index: usize) -> Option<&str>
index
.source§fn iter_fields(&self) -> FieldIter<'_>
fn iter_fields(&self) -> FieldIter<'_>
source§fn clone_dynamic(&self) -> DynamicStruct
fn clone_dynamic(&self) -> DynamicStruct
DynamicStruct
.source§impl TypePath for ParticleSystem
impl TypePath for ParticleSystem
source§fn type_path() -> &'static str
fn type_path() -> &'static str
source§fn short_type_path() -> &'static str
fn short_type_path() -> &'static str
source§fn type_ident() -> Option<&'static str>
fn type_ident() -> Option<&'static str>
source§fn crate_name() -> Option<&'static str>
fn crate_name() -> Option<&'static str>
source§impl Typed for ParticleSystemwhere
Self: Any + Send + Sync,
usize: FromReflect + TypePath,
ParticleTexture: FromReflect + TypePath,
Option<Vec2>: FromReflect + TypePath,
ValueOverTime: FromReflect + TypePath,
EmitterShape: FromReflect + TypePath,
JitteredValue: FromReflect + TypePath,
Vec<VelocityModifier>: FromReflect + TypePath,
ColorOverTime: FromReflect + TypePath,
bool: FromReflect + TypePath,
f32: FromReflect + TypePath,
Option<f32>: FromReflect + TypePath,
Option<JitteredValue>: FromReflect + TypePath,
Vec<ParticleBurst>: FromReflect + TypePath,
ParticleSpace: FromReflect + TypePath,
impl Typed for ParticleSystemwhere
Self: Any + Send + Sync,
usize: FromReflect + TypePath,
ParticleTexture: FromReflect + TypePath,
Option<Vec2>: FromReflect + TypePath,
ValueOverTime: FromReflect + TypePath,
EmitterShape: FromReflect + TypePath,
JitteredValue: FromReflect + TypePath,
Vec<VelocityModifier>: FromReflect + TypePath,
ColorOverTime: FromReflect + TypePath,
bool: FromReflect + TypePath,
f32: FromReflect + TypePath,
Option<f32>: FromReflect + TypePath,
Option<JitteredValue>: FromReflect + TypePath,
Vec<ParticleBurst>: FromReflect + TypePath,
ParticleSpace: FromReflect + TypePath,
Auto Trait Implementations§
impl !RefUnwindSafe for ParticleSystem
impl Send for ParticleSystem
impl Sync for ParticleSystem
impl Unpin for ParticleSystem
impl !UnwindSafe for ParticleSystem
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
[ShaderType
] for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId) )
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
fn get_components(self, func: &mut impl FnMut(StorageType, OwningPtr<'_>))
source§impl<T> DynamicTypePath for Twhere
T: TypePath,
impl<T> DynamicTypePath for Twhere
T: TypePath,
source§fn reflect_type_path(&self) -> &str
fn reflect_type_path(&self) -> &str
TypePath::type_path
.source§fn reflect_short_type_path(&self) -> &str
fn reflect_short_type_path(&self) -> &str
source§fn reflect_type_ident(&self) -> Option<&str>
fn reflect_type_ident(&self) -> Option<&str>
TypePath::type_ident
.source§fn reflect_crate_name(&self) -> Option<&str>
fn reflect_crate_name(&self) -> Option<&str>
TypePath::crate_name
.source§fn reflect_module_path(&self) -> Option<&str>
fn reflect_module_path(&self) -> Option<&str>
source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given World
.source§impl<S> GetField for Swhere
S: Struct,
impl<S> GetField for Swhere
S: Struct,
source§impl<T> GetPath for T
impl<T> GetPath for T
source§fn reflect_path<'p>(
&self,
path: impl ReflectPath<'p>
) -> Result<&(dyn Reflect + 'static), ReflectPathError<'p>>
fn reflect_path<'p>( &self, path: impl ReflectPath<'p> ) -> Result<&(dyn Reflect + 'static), ReflectPathError<'p>>
path
. Read moresource§fn reflect_path_mut<'p>(
&mut self,
path: impl ReflectPath<'p>
) -> Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>
fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p> ) -> Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>
path
. Read moresource§fn path<'p, T>(
&self,
path: impl ReflectPath<'p>
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
fn path<'p, T>(
&self,
path: impl ReflectPath<'p>
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
path
. Read moresource§fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
path
. Read more