Skip to main content

Particle

Represents a particle that can be spawned and modified

Obtained by indexing the ParticleAPI

Exists as an object-oriented alternative to particles:addParticle()

For the examples on this page assume:

myParticle = particles["explosion"]

spawn()

Spawns the particle with its current properties (set with the other functions)

Example:

myParticle:spawn()

setPos(Vector3)

Sets the position of the particle

Example:

myParticle:setPos(player:getPos())

getPos()

Gets the position of the particle

Example:

myParticle:getPos()

setColor(Vector3 or Vector4)

Sets the particle color, most particles don't support it. The alpha value can be excluded

Example:

myParticle:setColor(0, 0, 1)

getColor()

Gets the color as set by setcolor

Example:

myParticle:getColor()

setScale(Vector3)

Sets the scale of the particle

Example:

myParticle:setScale(2, 2, 2)

getScale()

Gets the scale of the particle

Example:

myParticle:getScale()

setVelocity(Vector3)

Sets the velocity of the particle

Example:

myParticle:setVelocity(2, 2, 2)

getVelocity()

Gets the velocity of the particle

Example:

myParticle:getVelocity()

setLifetime(integer)

Sets how long the particle should stay in the world. Particles with animations will animate in relation to their life left, so longer lives will make the animation play slower.

Example:

myParticle:setLifetime(200)

getLifetime()

Gets the lifetime

Example:

myParticle:getLifetime()

setPower(number)

Multiplies the particle's velocity every time it's run

Example:

myParticle:setPower(5)

getPower()

Silly power

caution

getPower doesn't get the particle's actual power, but the number last passed into setPower

Example:

myParticle:getPower()

setGravity(number)

Sets the strength of gravity

Example:

myParticle:setGravity(5)

getGravity()

Gets the gravity value

Example:

myParticle:getGravity()

setPhysics(bool)

Sets if the particle will experience physics

Example:

myParticle:setPhysics(false)

hasPhysics()

Gets if the particle has physics

Example:

myParticle:hasPhysics()

setSize(number)

Sets the scale of the particle, identical to setScale

Example:

myParticle:setSize(5)

getSize()

Gets the size of the particle

Example:

myParticle:getSize()

isAlive()

Gets if the particle is still in the world

Example:

myParticle:isAlive()