rParticle

The super light weight and highly customizable 2D particle system for Roblox.

GitHub Repository | Download | DevForum Post

Getting Started

rParticle has been designed to give the programmer as much control over how 2D particles are handled as possible.


Installation

Installing rParticle into your game is easy!

  1. First visit our downloads page and grab the rbxm file.
  2. Open your game in Roblox Studio and right click on ReplicatedStorage (or anyother location you'de like to install the module to). Select Insert from File and then select the downloaded module from step 1.
  3. You are done! Now, require the module into the script which will be using rParticle.

API Reference

Scroll to the next section for examples.

Particle Emitter

The Particle Emitter object is responsible for managing and handling all 2D particles.


Properties

rate

The number of particles to be emitted per second.

Default: 5


onSpawn

A callback function called when a particle is spawned.

Passed Values: particle


onUpdate

A callback function called when a particle is updated.

Passed Values: particle, delta



Global Functions

ParticleEmitter.new(hook, particle)

Creates a new ParticleEmitter instance

hook This is a UI Element (like a frame) which the emitter will use as a host for its operations. Generated particles will be parented to the hook and any operation on an individual particle is relative to the hook element. For example, if a particles position is set upon it spawning, the location in which the particle will appear will be relative to the location of the hook element.

particle This is any singular UI Element (like a frame) which the emitter will use as the particle to be emitted. These particles can contain scripts and other elements.


Object Functions

:Destroy()

Destroys the ParticleEmitter instance


:Emit(count)

Emits a particle

count This is the number of particles to be emitted.

Note: This feature is not currently available in the current release. If you'd like to use it, please download the lastest code from the repository and use that instead.


Particle

The Particle object represents a particle.


Properties

element

The UI Element which this particle represents.


age

The amount of time in seconds the particle has been alive.


maxAge

The max amount of time in seconds the particle can be alive.


position

The location of the particle relative to the hook.


velocity

This is a placeholder which is intended to be used when writing movement code for particle.


Object Functions

:Destroy()

Destroys the Particle instance


Example

            
local ParticleEmitter = require(game.ReplicatedStorage.ParticleEmitter).new(script.Parent, game.ReplicatedStorage:WaitForChild("ParticleVP"));
ParticleEmitter.rate = 10;

ParticleEmitter.onSpawn = function(particle)
    particle.velocity = Vector2.new(math.random(-700, 700), 500);
    particle.maxAge = 10;
end

ParticleEmitter.onUpdate = function(particle, deltaTime)
    particle.velocity = particle.velocity - Vector2.new(0, 10);
    particle.position = particle.position - (particle.velocity/3 * deltaTime);
end