Table of Contents

Class GpuParticles2D

Namespace
Godot
Assembly
GodotSharp.dll

2D particle node used to create a variety of particle systems and effects. GpuParticles2D features an emitter that generates some number of particles at a given rate.

Use the ProcessMaterial property to add a ParticleProcessMaterial to configure particle appearance and behavior. Alternatively, you can add a ShaderMaterial which will be applied to all particles.

2D particles can optionally collide with LightOccluder2D, but they don't collide with PhysicsBody2D nodes.

[GodotClassName("GPUParticles2D")]
public class GpuParticles2D : Node2D, IDisposable
Inheritance
GpuParticles2D
Implements
Inherited Members

Constructors

GpuParticles2D()

public GpuParticles2D()

Properties

Amount

The number of particles to emit in one emission cycle. The effective emission rate is (amount * amount_ratio) / lifetime particles per second. Higher values will increase GPU requirements, even if not all particles are visible at a given time or if AmountRatio is decreased.

Note: Changing this value will cause the particle system to restart. To avoid this, change AmountRatio instead.

public int Amount { get; set; }

Property Value

int

AmountRatio

The ratio of particles that should actually be emitted. If set to a value lower than 1.0, this will set the amount of emitted particles throughout the lifetime to amount * amount_ratio. Unlike changing Amount, changing AmountRatio while emitting does not affect already-emitted particles and doesn't cause the particle system to restart. AmountRatio can be used to create effects that make the number of emitted particles vary over time.

Note: Reducing the AmountRatio has no performance benefit, since resources need to be allocated and processed for the total Amount of particles regardless of the AmountRatio. If you don't intend to change the number of particles emitted while the particles are emitting, make sure AmountRatio is set to 1 and change Amount to your liking instead.

public float AmountRatio { get; set; }

Property Value

float

CollisionBaseSize

Multiplier for particle's collision radius. 1.0 corresponds to the size of the sprite. If particles appear to sink into the ground when colliding, increase this value. If particles appear to float when colliding, decrease this value. Only effective if CollisionMode is Rigid or HideOnContact.

Note: Particles always have a spherical collision shape.

public float CollisionBaseSize { get; set; }

Property Value

float

DrawOrder

Particle draw order. Uses GpuParticles2D.DrawOrderEnum values.

public GpuParticles2D.DrawOrderEnum DrawOrder { get; set; }

Property Value

GpuParticles2D.DrawOrderEnum

Emitting

If true, particles are being emitted. Emitting can be used to start and stop particles from emitting. However, if OneShot 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.

public bool Emitting { get; set; }

Property Value

bool

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.

public float Explosiveness { get; set; }

Property Value

float

FixedFps

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.

public int FixedFps { get; set; }

Property Value

int

FractDelta

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

public bool FractDelta { get; set; }

Property Value

bool

InterpToEnd

Causes all the particles in this node to interpolate towards the end of their lifetime.

Note: This only works when used with a ParticleProcessMaterial. It needs to be manually implemented for custom process shaders.

public float InterpToEnd { get; set; }

Property Value

float

Interpolate

Enables particle interpolation, which makes the particle movement smoother when their FixedFps is lower than the screen refresh rate.

public bool Interpolate { get; set; }

Property Value

bool

Lifetime

The amount of time each particle will exist (in seconds). The effective emission rate is (amount * amount_ratio) / lifetime particles per second.

public double Lifetime { get; set; }

Property Value

double

LocalCoords

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

public bool LocalCoords { get; set; }

Property Value

bool

OneShot

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

public bool OneShot { get; set; }

Property Value

bool

Preprocess

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

public double Preprocess { get; set; }

Property Value

double

ProcessMaterial

Material for processing particles. Can be a ParticleProcessMaterial or a ShaderMaterial.

public Material ProcessMaterial { get; set; }

Property Value

Material

Randomness

Emission lifetime randomness ratio.

public float Randomness { get; set; }

Property Value

float

SpeedScale

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

public double SpeedScale { get; set; }

Property Value

double

SubEmitter

Path to another GpuParticles2D node that will be used as a subemitter (see SubEmitterMode). Subemitters can be used to achieve effects such as fireworks, sparks on collision, bubbles popping into water drops, and more.

Note: When SubEmitter is set, the target GpuParticles2D node will no longer emit particles on its own.

public NodePath SubEmitter { get; set; }

Property Value

NodePath

Texture

Particle texture. If null, particles will be squares with a size of 1×1 pixels.

Note: To use a flipbook texture, assign a new CanvasItemMaterial to the GpuParticles2D's Material property, then enable ParticlesAnimation and set ParticlesAnimHFrames, ParticlesAnimVFrames, and ParticlesAnimLoop to match the flipbook texture.

public Texture2D Texture { get; set; }

Property Value

Texture2D

TrailEnabled

If true, enables particle trails using a mesh skinning system.

Note: Unlike GpuParticles3D, the number of trail sections and subdivisions is set with the TrailSections and TrailSectionSubdivisions properties.

public bool TrailEnabled { get; set; }

Property Value

bool

TrailLifetime

The amount of time the particle's trail should represent (in seconds). Only effective if TrailEnabled is true.

public double TrailLifetime { get; set; }

Property Value

double

TrailSectionSubdivisions

The number of subdivisions to use for the particle trail rendering. Higher values can result in smoother trail curves, at the cost of performance due to increased mesh complexity. See also TrailSections. Only effective if TrailEnabled is true.

public int TrailSectionSubdivisions { get; set; }

Property Value

int

TrailSections

The number of sections to use for the particle trail rendering. Higher values can result in smoother trail curves, at the cost of performance due to increased mesh complexity. See also TrailSectionSubdivisions. Only effective if TrailEnabled is true.

public int TrailSections { get; set; }

Property Value

int

VisibilityRect

The Rect2 that determines the node's region which needs to be visible on screen for the particle system to be active.

Grow the rect if particles suddenly appear/disappear when the node enters/exits the screen. The Rect2 can be grown via code or with the Particles → Generate Visibility Rect editor tool.

public Rect2 VisibilityRect { get; set; }

Property Value

Rect2

Methods

CaptureRect()

Returns a rectangle containing the positions of all existing particles.

Note: When using threaded rendering this method synchronizes the rendering thread. Calling it often may have a negative impact on performance.

public Rect2 CaptureRect()

Returns

Rect2

ConvertFromParticles(Node)

Sets this node's properties to match a given CpuParticles2D node.

public void ConvertFromParticles(Node particles)

Parameters

particles Node

EmitParticle(Transform2D, Vector2, Color, Color, uint)

Emits a single particle. Whether xform, velocity, color and custom are applied depends on the value of flags. See GpuParticles2D.EmitFlags.

public void EmitParticle(Transform2D xform, Vector2 velocity, Color color, Color custom, uint flags)

Parameters

xform Transform2D
velocity Vector2
color Color
custom Color
flags uint

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

Restart()

Restarts all the existing particles.

public void Restart()

Events

Finished

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

Note: Due to the particles being computed on the GPU there might be a delay before the signal gets emitted.

public event Action Finished

Event Type

Action