Table of Contents

Class CPUParticles2D

A CPU-based 2D particle emitter.

Inheritance
CPUParticles2D

Remarks

CPU-based 2D particle node used to create a variety of particle systems and effects.

See also GPUParticles2D, which provides the same functionality with hardware acceleration, but may not run on older devices.

See Also

Properties

amount

Number of particles emitted in one emission cycle.

var amount : int = 8

Property Value

int

Remarks

  • void set_amount(int value)
  • int get_amount

angle_curve

Each particle's rotation will be animated along this Curve. Should be a unit Curve.

var angle_curve : Curve

Property Value

Curve

Remarks

angle_max

Maximum initial rotation applied to each particle, in degrees.

var angle_max : float = 0.0

Property Value

float

Remarks

angle_min

Minimum equivalent of angle_max.

var angle_min : float = 0.0

Property Value

float

Remarks

angular_velocity_curve

Each particle's angular velocity will vary along this Curve. Should be a unit Curve.

var angular_velocity_curve : Curve

Property Value

Curve

Remarks

angular_velocity_max

Maximum initial angular velocity (rotation speed) applied to each particle in degrees per second.

var angular_velocity_max : float = 0.0

Property Value

float

Remarks

angular_velocity_min

Minimum equivalent of angular_velocity_max.

var angular_velocity_min : float = 0.0

Property Value

float

Remarks

anim_offset_curve

Each particle's animation offset will vary along this Curve. Should be a unit Curve.

var anim_offset_curve : Curve

Property Value

Curve

Remarks

anim_offset_max

Maximum animation offset that corresponds to frame index in the texture. 0 is the first frame, 1 is the last one. See particles_animation.

var anim_offset_max : float = 0.0

Property Value

float

Remarks

anim_offset_min

Minimum equivalent of anim_offset_max.

var anim_offset_min : float = 0.0

Property Value

float

Remarks

anim_speed_curve

Each particle's animation speed will vary along this Curve. Should be a unit Curve.

var anim_speed_curve : Curve

Property Value

Curve

Remarks

anim_speed_max

Maximum particle animation speed. Animation speed of 1 means that the particles will make full 0 to 1 offset cycle during lifetime, 2 means 2 cycles etc.

With animation speed greater than 1, remember to enable particles_anim_loop property if you want the animation to repeat.

var anim_speed_max : float = 0.0

Property Value

float

Remarks

anim_speed_min

Minimum equivalent of anim_speed_max.

var anim_speed_min : float = 0.0

Property Value

float

Remarks

color

Each particle's initial color. If texture is defined, it will be multiplied by this color.

var color : Color = Color(1, 1, 1, 1)

Property Value

Color

Remarks

color_initial_ramp

Each particle's initial color will vary along this Gradient (multiplied with color).

var color_initial_ramp : Gradient

Property Value

Gradient

Remarks

color_ramp

Each particle's color will vary along this Gradient over its lifetime (multiplied with color).

var color_ramp : Gradient

Property Value

Gradient

Remarks

damping_curve

Damping will vary along this Curve. Should be a unit Curve.

var damping_curve : Curve

Property Value

Curve

Remarks

damping_max

The maximum rate at which particles lose velocity. For example value of 100 means that the particle will go from 100 velocity to 0 in 1 second.

var damping_max : float = 0.0

Property Value

float

Remarks

damping_min

Minimum equivalent of damping_max.

var damping_min : float = 0.0

Property Value

float

Remarks

direction

Unit vector specifying the particles' emission direction.

var direction : Vector2 = Vector2(1, 0)

Property Value

Vector2

Remarks

draw_order

Particle draw order. Uses DrawOrder values.

var draw_order : int = 0

Property Value

int

Remarks

  • void set_draw_order(int value)
  • int get_draw_order

emission_colors

Sets the Colors to modulate particles by when using CPUParticles2D.EMISSION_SHAPE_POINTS or CPUParticles2D.EMISSION_SHAPE_DIRECTED_POINTS.

var emission_colors : PackedColorArray

Property Value

PackedColorArray

Remarks

emission_normals

Sets the direction the particles will be emitted in when using CPUParticles2D.EMISSION_SHAPE_DIRECTED_POINTS.

var emission_normals : PackedVector2Array

Property Value

PackedVector2Array

Remarks

emission_points

Sets the initial positions to spawn particles when using CPUParticles2D.EMISSION_SHAPE_POINTS or CPUParticles2D.EMISSION_SHAPE_DIRECTED_POINTS.

var emission_points : PackedVector2Array

Property Value

PackedVector2Array

Remarks

emission_rect_extents

The rectangle's extents if emission_shape is set to CPUParticles2D.EMISSION_SHAPE_RECTANGLE.

var emission_rect_extents : Vector2

Property Value

Vector2

Remarks

  • void set_emission_rect_extents(Vector2 value)
  • Vector2 get_emission_rect_extents

emission_shape

Particles will be emitted inside this region. See EmissionShape for possible values.

var emission_shape : int = 0

Property Value

int

Remarks

  • void set_emission_shape(int value)
  • int get_emission_shape

emission_sphere_radius

The sphere's radius if emission_shape is set to CPUParticles2D.EMISSION_SHAPE_SPHERE.

var emission_sphere_radius : float

Property Value

float

Remarks

  • void set_emission_sphere_radius(float value)
  • float get_emission_sphere_radius

emitting

If true, particles are being emitted. emitting can be used to start and stop particles from emitting. However, if one_shot is true setting emitting to true will not restart the emission cycle until after all active particles finish processing. You can use the finished signal to be notified once all active particles finish processing.

var emitting : bool = true

Property Value

bool

Remarks

  • void set_emitting(bool value)
  • bool is_emitting

explosiveness

How rapidly particles in an emission cycle are emitted. If greater than 0, there will be a gap in emissions before the next cycle begins.

var explosiveness : float = 0.0

Property Value

float

Remarks

  • void set_explosiveness_ratio(float value)
  • float get_explosiveness_ratio

fixed_fps

The particle system's frame rate is fixed to a value. For example, changing the value to 2 will make the particles render at 2 frames per second. Note this does not slow down the simulation of the particle system itself.

var fixed_fps : int = 0

Property Value

int

Remarks

  • void set_fixed_fps(int value)
  • int get_fixed_fps

fract_delta

If true, results in fractional delta calculation which has a smoother particles display effect.

var fract_delta : bool = true

Property Value

bool

Remarks

  • void set_fractional_delta(bool value)
  • bool get_fractional_delta

gravity

Gravity applied to every particle.

var gravity : Vector2 = Vector2(0, 980)

Property Value

Vector2

Remarks

hue_variation_curve

Each particle's hue will vary along this Curve. Should be a unit Curve.

var hue_variation_curve : Curve

Property Value

Curve

Remarks

hue_variation_max

Maximum initial hue variation applied to each particle. It will shift the particle color's hue.

var hue_variation_max : float = 0.0

Property Value

float

Remarks

hue_variation_min

Minimum equivalent of hue_variation_max.

var hue_variation_min : float = 0.0

Property Value

float

Remarks

initial_velocity_max

Maximum initial velocity magnitude for each particle. Direction comes from direction and spread.

var initial_velocity_max : float = 0.0

Property Value

float

Remarks

initial_velocity_min

Minimum equivalent of initial_velocity_max.

var initial_velocity_min : float = 0.0

Property Value

float

Remarks

lifetime

Amount of time each particle will exist.

var lifetime : float = 1.0

Property Value

float

Remarks

  • void set_lifetime(float value)
  • float get_lifetime

lifetime_randomness

Particle lifetime randomness ratio.

var lifetime_randomness : float = 0.0

Property Value

float

Remarks

  • void set_lifetime_randomness(float value)
  • float get_lifetime_randomness

linear_accel_curve

Each particle's linear acceleration will vary along this Curve. Should be a unit Curve.

var linear_accel_curve : Curve

Property Value

Curve

Remarks

linear_accel_max

Maximum linear acceleration applied to each particle in the direction of motion.

var linear_accel_max : float = 0.0

Property Value

float

Remarks

linear_accel_min

Minimum equivalent of linear_accel_max.

var linear_accel_min : float = 0.0

Property Value

float

Remarks

local_coords

If true, particles use the parent node's coordinate space (known as local coordinates). This will cause particles to move and rotate along the CPUParticles2D node (and its parents) when it is moved or rotated. If false, particles use global coordinates; they will not move or rotate along the CPUParticles2D node (and its parents) when it is moved or rotated.

var local_coords : bool = false

Property Value

bool

Remarks

  • void set_use_local_coordinates(bool value)
  • bool get_use_local_coordinates

one_shot

If true, only one emission cycle occurs. If set true during a cycle, emission will stop at the cycle's end.

var one_shot : bool = false

Property Value

bool

Remarks

  • void set_one_shot(bool value)
  • bool get_one_shot

orbit_velocity_curve

Each particle's orbital velocity will vary along this Curve. Should be a unit Curve.

var orbit_velocity_curve : Curve

Property Value

Curve

Remarks

orbit_velocity_max

Maximum orbital velocity applied to each particle. Makes the particles circle around origin. Specified in number of full rotations around origin per second.

var orbit_velocity_max : float = 0.0

Property Value

float

Remarks

orbit_velocity_min

Minimum equivalent of orbit_velocity_max.

var orbit_velocity_min : float = 0.0

Property Value

float

Remarks

particle_flag_align_y

Align Y axis of particle with the direction of its velocity.

var particle_flag_align_y : bool = false

Property Value

bool

Remarks

  • void set_particle_flag(int particle_flag, bool enable)
  • bool get_particle_flag(int particle_flag)

preprocess

Particle system starts as if it had already run for this many seconds.

var preprocess : float = 0.0

Property Value

float

Remarks

  • void set_pre_process_time(float value)
  • float get_pre_process_time

radial_accel_curve

Each particle's radial acceleration will vary along this Curve. Should be a unit Curve.

var radial_accel_curve : Curve

Property Value

Curve

Remarks

radial_accel_max

Maximum radial acceleration applied to each particle. Makes particle accelerate away from the origin or towards it if negative.

var radial_accel_max : float = 0.0

Property Value

float

Remarks

radial_accel_min

Minimum equivalent of radial_accel_max.

var radial_accel_min : float = 0.0

Property Value

float

Remarks

randomness

Emission lifetime randomness ratio.

var randomness : float = 0.0

Property Value

float

Remarks

  • void set_randomness_ratio(float value)
  • float get_randomness_ratio

scale_amount_curve

Each particle's scale will vary along this Curve. Should be a unit Curve.

var scale_amount_curve : Curve

Property Value

Curve

Remarks

scale_amount_max

Maximum initial scale applied to each particle.

var scale_amount_max : float = 1.0

Property Value

float

Remarks

scale_amount_min

Minimum equivalent of scale_amount_max.

var scale_amount_min : float = 1.0

Property Value

float

Remarks

scale_curve_x

Each particle's horizontal scale will vary along this Curve. Should be a unit Curve.

split_scale must be enabled.

var scale_curve_x : Curve

Property Value

Curve

Remarks

  • void set_scale_curve_x(Curve value)
  • Curve get_scale_curve_x

scale_curve_y

Each particle's vertical scale will vary along this Curve. Should be a unit Curve.

split_scale must be enabled.

var scale_curve_y : Curve

Property Value

Curve

Remarks

  • void set_scale_curve_y(Curve value)
  • Curve get_scale_curve_y

seed

Sets the random seed used by the particle system. Only effective if use_fixed_seed is true.

var seed : int = 0

Property Value

int

Remarks

  • void set_seed(int value)
  • int get_seed

speed_scale

Particle system's running speed scaling ratio. A value of 0 can be used to pause the particles.

var speed_scale : float = 1.0

Property Value

float

Remarks

  • void set_speed_scale(float value)
  • float get_speed_scale

split_scale

If true, the scale curve will be split into x and y components. See scale_curve_x and scale_curve_y.

var split_scale : bool = false

Property Value

bool

Remarks

  • void set_split_scale(bool value)
  • bool get_split_scale

spread

Each particle's initial direction range from +spread to -spread degrees.

var spread : float = 45.0

Property Value

float

Remarks

tangential_accel_curve

Each particle's tangential acceleration will vary along this Curve. Should be a unit Curve.

var tangential_accel_curve : Curve

Property Value

Curve

Remarks

tangential_accel_max

Maximum tangential acceleration applied to each particle. Tangential acceleration is perpendicular to the particle's velocity giving the particles a swirling motion.

var tangential_accel_max : float = 0.0

Property Value

float

Remarks

tangential_accel_min

Minimum equivalent of tangential_accel_max.

var tangential_accel_min : float = 0.0

Property Value

float

Remarks

texture

Particle texture. If null, particles will be squares.

var texture : Texture2D

Property Value

Texture2D

Remarks

use_fixed_seed

If true, particles will use the same seed for every simulation using the seed defined in seed. This is useful for situations where the visual outcome should be consistent across replays, for example when using Movie Maker mode.

var use_fixed_seed : bool = false

Property Value

bool

Remarks

  • void set_use_fixed_seed(bool value)
  • bool get_use_fixed_seed

Methods

convert_from_particles(Node)

Sets this node's properties to match a given GPUParticles2D node with an assigned ParticleProcessMaterial.

void convert_from_particles(Node particles)

Parameters

particles Node

get_param_curve(int)

Qualifiers: const

Returns the Curve of the parameter specified by Parameter.

Curve get_param_curve(int param)

Parameters

param int

get_param_max(int)

Qualifiers: const

Returns the maximum value range for the given parameter.

float get_param_max(int param)

Parameters

param int

get_param_min(int)

Qualifiers: const

Returns the minimum value range for the given parameter.

float get_param_min(int param)

Parameters

param int

get_particle_flag(int)

Qualifiers: const

Returns the enabled state of the given particle flag (see ParticleFlags for options).

bool get_particle_flag(int particle_flag)

Parameters

particle_flag int

request_particles_process(float)

Requests the particles to process for extra process time during a single frame.

Useful for particle playback, if used in combination with use_fixed_seed or by calling CPUParticles2D.restart with parameter keep_seed set to true.

void request_particles_process(float process_time)

Parameters

process_time float

restart(bool)

Restarts the particle emitter.

If keep_seed is true, the current random seed will be preserved. Useful for seeking and playback.

void restart(bool keep_seed)

Parameters

keep_seed bool

set_param_curve(int, Curve)

Sets the Curve of the parameter specified by Parameter. Should be a unit Curve.

void set_param_curve(int param, Curve curve)

Parameters

param int
curve Curve

set_param_max(int, float)

Sets the maximum value for the given parameter.

void set_param_max(int param, float value)

Parameters

param int
value float

set_param_min(int, float)

Sets the minimum value for the given parameter.

void set_param_min(int param, float value)

Parameters

param int
value float

set_particle_flag(int, bool)

Enables or disables the given flag (see ParticleFlags for options).

void set_particle_flag(int particle_flag, bool enable)

Parameters

particle_flag int
enable bool

Events

finished

Emitted when all active particles have finished processing. When one_shot is disabled, particles will process continuously, so this is never emitted.

signal finished