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 https://github.com/JoelDesante/rParticle/releases/tag/1.2 | 1/15/2021
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
Inside of this
ViewportFrameI placed a model of my character and a
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
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 ParticalEmitter = require(game.ReplicatedStorage.ParticleEmitter).new(script.Parent, game.ReplicatedStorage:WaitForChild("ParticleVP")); ParticalEmitter.rate = 10; ParticalEmitter.onSpawn = function(particle) particle.velocity = Vector2.new(math.random(-700, 700), 500); particle.maxAge = 10; end ParticalEmitter.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
onUpdate()to handle the logic of the particles.
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!