This module aims to mimic the existing Roblox ParticleEmitter object to make it easier to create 2d particles and port over existing particle emitters (with a few tweaks of course!)
Short video of this module in action, along with a comparison:
Notable changes that you have to account for when making your own particle emitter:
Speed determines how much the particle progresses in pixels (offset) per second.
Size is in offset.
You can get and view the source code via Github or the Roblox Creator Store.
A quick usage example can be found within the Github provided above.
Replaced math.random with the Random class internally
Added .fromParticle constructor function which lets you create a 2d particle object using an existing particle emitter as a base
Example usage:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ParticleEmitter = require(ReplicatedStorage:WaitForChild("ParticleEmitter"))
-- Size & Speed are being set here because they work very differently
-- from regular ParticleEmitters
local sparklesEmitter = ParticleEmitter.fromParticle(script.ParticleEmitter)
sparklesEmitter.Size = NumberSequence.new({
NumberSequenceKeypoint.new(0, 3.75),
NumberSequenceKeypoint.new(0.175, 15),
NumberSequenceKeypoint.new(1, 0),
})
sparklesEmitter.Speed = 15
sparklesEmitter.Parent = script.Parent
Nope, it only took a few hours because I had to come up with ideas for these particles
Refer to the example given above or within the Github to get started
Sorry these demonstrations were made specifically for my game so I can’t make them public. However I can make some example particles next week since I’m on vacation right now.
--Script 2
local healthGainEmitter = Visuals.CreateHealthGainEmitter(ParticleFrame)
-- this fires when my local player gains more than 1% max hp
healthGainEmitter:Emit(1)
Emitters no longer create a new RenderStepped loop. Connections now have to be started manually via the new methods listed above. Alternatively, you can ditch the bind methods entirely and just update the emitter yourself if needed.
Added support for the Acceleration property.
Added NumberRange to ZOffset type.
Added AspectRatio property. This allows you to apply an aspect ratio to particles.
Example usage:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ParticleEmitter = require(ReplicatedStorage:WaitForChild("ParticleEmitter"))
-- Short PSA for using the Acceleration property
-- X: (+) = Right, (-) = Left
-- Y: (+) = Down, (-) = Up
-- the direction is weird because it's relative to your screen
local sparklesEmitter = ParticleEmitter.fromParticle(script.ParticleEmitter)
sparklesEmitter.AspectRatio = 1 / 2
sparklesEmitter.Acceleration = Vector2.new(40, 40) -- Bottom Right
sparklesEmitter.Parent = script.Parent
sparklesEmitter:BindToRenderStepped() -- bind emitter to RenderStepped
sparklesEmitter:Unbind() -- unbinds current connection
while true do
local deltaTime = task.wait(1)
sparklesEmitter:Update(deltaTime) -- update it yourself if you want to
end
You can get and view the source code via Github or the Roblox Creator Store.
A quick usage example can be found within the Github provided above.
I still actively use this module to this day for my UI, but I just haven’t had a reason to add any other features at the moment. I’m willing to look through pull requests on the github repository if anyone is interested in contributing.