Hey. I’m currently working on a particles system. While working on the class which is responsible for spawning the particles, I realized that I would require the use of many parameters. Currently, there are a total of 12 parameters required to create a new object.
It looks a little something like this:
function Particles.new(model, origin, directionRange, intialVelocityRange, accelerationRange, lifeTime,
dragCoefficient, gravityEnabled, collisions, inheritsOriginVelocity, restitutionCoefficient, spawnRate)
local self = setmetatable({}, Particles)
-- Settings:
self._model = model
self._origin = origin
self._directionRange = directionRange
self._intialVelocityRange = intialVelocityRange
self._accelerationRange = accelerationRange
self._liftTime = lifeTime
self._dragCoefficient = dragCoefficient
self._gravityEnabled = gravityEnabled
self._collisionsEnabled = collisions
self._inheritsOriginVelocity = inheritsOriginVelocity
self._restitutionCoefficient = restitutionCoefficient
self._spawnRate = spawnRate
-- Variables:
self._activeParticles = {}
-- Connections:
RunService.RenderStepped:Connect(function(dt)
self:update(dt)
end)
return self
end
(Sorry for the weird indentation the formatting was not playing nice with me lol)
Now, as you can see, having that many parameters is a real eyesore. I would love to hear some suggestions on how I can potentially shorten down on the amount of parameters used or make it look nicer at least. Thanks.