Hi, this is my first time making an Open Source project, so please feel free to give me lots of constructive criticism.
Recently updated to version 1.2.1 Release rParticle 1.2.1 · joeldesante/rParticle · GitHub | 5/6/2022
rParticle
The Light Weight, Open Source, GUI Particle System.
Source Code | Download | Docs
What is rParticle?
rParticle is a small module (around 80 lines of code) which was made with the sole intention of allowing developers to quickly and easily make 2D GUI particle systems.
rParticle is set up in such a way that basically all of the particle “logic” is handled by the creator while the tracking, updating, data, and “rendering” of the particles are handled by the module.
How do I use rParticle?
It is my opinion that rParticle is exceedingly easy to use. I was able to create the following effect in only ~28 lines of code:
Here is how this 3D Gui particle effect is done:
Step 1: Install rParticle
Just download the module and put it somewhere that you can easily access it. I tend to put mine in ReplicatedStorage.
Step 2: Create your particle
rParticle was created to give as much control over the particle as possible to the developer. This means that the particle can be (for the most part) any GUI Object (ie Frame, Button, TextLabel, ViewportFrame, etc…)
In this example, I created a
ViewportFrame
calledParticleVP
.
Inside of thisViewportFrame
I placed a model of my character and aLocalScript
.The contents of the local script are:
local RunService = game:GetService("RunService") local Model = script.Parent.Yooogle local part = Model.HumanoidRootPart local Viewport = script.Parent local Camera = Instance.new("Camera") Camera.Parent = Viewport Viewport.CurrentCamera = Camera RunService.RenderStepped:Connect(function(delta) Camera.CFrame = CFrame.new(part.CFrame.p + Vector3.new(-5,3,5), part.Position) Model:SetPrimaryPartCFrame(part.CFrame * CFrame.Angles(0, math.rad(delta*100), 0)) end)
Finally, I stored the Particle in
ReplicatedStorage
Step 3: Create the ParticleEmitter
To emit the particles, you will need two components.
- A particle to emit.
- An element to “hook” into.
In this example, I used a
Frame
, but you could use pretty much any GUI object.The code I wrote to emit the particles is as follows:
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
On the first line, I am including the ParticleEmitter module and creating a new ParticleEmiter using
.new()
. The first argument I pass in is the “hook” and the second is the particle.As you can see, there are various properties that you can set, many of which are listed on the GitHub README.
In this example, I am setting the rate of the emitter to 10 particles per second.
Then, below, I modify the callbacks
onSpawn()
andonUpdate()
to handle the logic of the particles.
Conclusion
I hope this module helps some people out there. Let me know if there are any questions, as I am aware that my documentation might leave some things to be desired. I am still new to the Open Source world, so I will be working to get better at writing documentation.
Thank you for reading!