Repository navigation
Animating Particles #3 ‐ Velocity
You might've noticed that so far we've only covered basic ways to alter the initial velocity of spawned particles, such as:
-
StartDirection: Determines which direction particles travel in. -
StartSpeed: Determines the initial speed of a particle. -
DirectionSpread: Determines how spread particles are relative to the emitter'sStartDirection.
Fortunately, Palette offers plenty of other ways to alter the velocity of particles.
You can adjust the gravitational force applied to particles each frame by setting the GravityModifier field. You can set it to a number or a table with a Min and Max field to randomize it for each particle. A positive value will apply a downwards force to each particle, while a negative value will apply an upwards force.
Here's an example of it in action:
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.DirectionSpread = 30
emitter.StartSpeed = { Min = 5, Max = 10 }
emitter.GravityModifier = 1.32026-11-22.14-18-21.mp4
ForceOverLifetime is a module that allows you to alter a particle's acceleration over its lifetime. It's structured identically to various other lifetime modules such as RotationOverLifetime and ScaleOverLifetime.
Below is an example of ForceOverLifetime in action. Each particle begins with no acceleration, but over the course of its lifetime the acceleration on the X-axis gradually increases until it becomes 0.1 units per frame at the end of its lifetime:
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.StartSpeed = 3
emitter.Lifetime = 90
emitter.ForceOverLifetime.Enabled = true
emitter.ForceOverLifetime.Keys = {
{ Time = 0, Value = Vector(0, 0) },
{ Time = 1, Value = Vector(0.1, 0) }
}2026-11-22.14-45-10.mp4
VelocityOverLifetime is a module that allows further customization of a particle's movement. Unlike ForceOverLifetime, its values don't build up over time; they're applied as-is every frame. There are four main fields:
-
LinearVelocity: Allows particles to move in a fixed direction. -
OrbitalVelocity: Allows particles to move around a center point. -
Radial: Allows particles to move away from or towards the center point. -
SpeedModifier: Multiplies the speed of the particle's movement, including the three fields above.
LinearVelocity is a Vector that is added to each particle's movement every frame. For example, a value of Vector(1, 0) causes each particle to move right every frame on top of whatever it's already doing.
Below is an example of using LinearVelocity, where each particle rises upwards but steadily drifts to the right:
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.StartSpeed = 2
emitter.VelocityOverLifetime.Enabled = true
emitter.VelocityOverLifetime.LinearVelocity = Vector(1, 0)2026-11-22.17-56-01.mp4
Comparing this with the ForceOverLifetime example, notice how LinearVelocity moves each particle at the same rate for their whole life, whereas ForceOverLifetime applies acceleration.
OrbitalVelocity is a number that causes particles to spin around a center point, measured in degrees per frame. The center point is the position where each particle spawned. Positive values cause particles to spin clockwise, and negative values spin them counterclockwise.
Here is an example:
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.StartSpeed = 5
emitter.VelocityOverLifetime.Enabled = true
emitter.VelocityOverLifetime.OrbitalVelocity = 62026-11-22.18-05-51.mp4
You can adjust the center of the orbit by changing the OrbitalOffset field inside VelocityOverLifetime. OrbitalOffset is a Vector that's added to each particle's spawn position. For example, a value of Vector(0, 40) causes each particle to circle around a point 40 units below where it spawned.
2026-11-22.18-09-59.mp4
Radial is a number that allows particles to move away from the center of orbit. Giving it a negative value will cause them to move towards the center of orbit.
Here is an example where the combination of Radial and OrbitalVelocity can be used to achieve a spiral-like effect:
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.StartSpeed = 2
emitter.Lifetime = 180
emitter.VelocityOverLifetime.Enabled = true
emitter.VelocityOverLifetime.OrbitalVelocity = 6
emitter.VelocityOverLifetime.Radial = 0.52026-11-22.18-18-45.mp4
SpeedModifier is a multiplier for everything in this module. The default value is 1, which means it does nothing. A value of 0.5 causes particles to move at half speed, 2 causes them to move at double speed, 0 freezes particles in place, and so on.
Space determines whether LinearVelocity and OrbitalOffset follow the emitter's Orientation. There are two values it supports:
-
"Local"(default): The vectors are rotated by the emitter'sOrientation. -
"World": The vectors are used as-is regardless of the emitter's orientation.
Below is an example of an emitter that's rotated by 90 degrees but with Space set to "World". Note how particles still move to the right despite the emitter's orientation:
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.Orientation = 90
emitter.StartSpeed = 2
emitter.VelocityOverLifetime.Enabled = true
emitter.VelocityOverLifetime.LinearVelocity = Vector(1, 0)
emitter.VelocityOverLifetime.Space = "World"2026-11-22.18-34-25.mp4
However, if we set Space to "Local", notice how the particles are now affected by the emitter's orientation:
2026-11-22.18-36-13.mp4
ForceOverLifetime also has its own Space field that works the exact same way!
LimitVelocityOverLifetime is a module that serves two different purposes: allowing particles to slow down every frame and adding a speed cap to each particle. It has three fields:
-
MaxSpeed(default: no limit): How fast particles are allowed to move, in units per frame. -
Dampen(default:0.5): How strongly particles are pulled back toMaxSpeedwhen their speed exceeds it. Values must be between0and1. Setting it to1causes particles to be snapped toMaxSpeedinstantly, while lower values make it more gradual. -
Drag(default:0): How much particles are slowed down every frame. Values must be between0and1. It works as a percentage. For example, a value of0.1would cause particles to be slowed down by 10% every frame.
Like other modules, you need to set Enabled to true to use it.
Remember the gravity example from earlier? Because GravityModifier adds gravity to a particle's velocity every frame, particles will fall faster and faster. We can use MaxSpeed to prevent them from speeding up past a certain point and Dampen to pull the particles back to MaxSpeed:
local room = Game():GetRoom()
local spawnPos = room:GetCenterPos()
local emitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
emitter.DirectionSpread = 30
emitter.StartSpeed = { Min = 5, Max = 10 }
emitter.GravityModifier = 1.3
emitter.LimitVelocityOverLifetime.Enabled = true
emitter.LimitVelocityOverLifetime.MaxSpeed = 3
emitter.LimitVelocityOverLifetime.Dampen = 0.72026-11-22.21-48-22.mp4
Using what we've learned on this page, here's a cool swirl effect that follows players!
local mod = RegisterMod("Palette Test", 1)
local Palette = include("palette_scripts.palette")
Palette:Init(mod)
mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, function()
local player = Isaac.GetPlayer()
local swirl = Palette:CreateParticleEmitter("gfx/particle.png", player.Position)
swirl.RenderMode = "BehindEntities"
swirl.MaxParticles = 150
swirl.ParticleRate = 40
swirl.Lifetime = { Min = 40, Max = 60 }
swirl.StartSpeed = { Min = 0.6, Max = 1.4 }
swirl.DirectionSpread = 180
swirl.StartScale = {
Min = Vector(0.3, 0.3),
Max = Vector(0.6, 0.6)
}
swirl.StartColor = {
Min = KColor(0.5, 0.2, 1.0, 0.8),
Max = KColor(0.3, 0.8, 1.0, 1.0)
}
swirl.VelocityOverLifetime.Enabled = true
swirl.VelocityOverLifetime.OrbitalVelocity = 7
swirl.VelocityOverLifetime.Radial = 0.8
swirl.ScaleOverLifetime.Enabled = true
swirl.ScaleOverLifetime.Keys = {
{ Time = 0, Value = Vector(1, 1) },
{ Time = 1, Value = Vector(0, 0) }
}
swirl.ColorOverLifetime.Enabled = true
swirl.ColorOverLifetime.Gradient.AlphaKeys = {
{ Time = 0, Value = 0 },
{ Time = 0.15, Value = 1 },
{ Time = 1, Value = 0 }
}
swirl:FollowEntity(player, Vector(0, -10))
local sparkles = Palette:CreateParticleEmitter("gfx/particle.png", player.Position)
sparkles.MaxParticles = 40
sparkles.ParticleRate = 6
sparkles.Lifetime = { Min = 60, Max = 90 }
sparkles.StartSpeed = { Min = 0.2, Max = 0.6 }
sparkles.DirectionSpread = 180
sparkles.RenderMode = "BehindEntities"
sparkles.StartScale = {
Min = Vector(0.05, 0.05),
Max = Vector(0.12, 0.12)
}
sparkles.StartColor = {
Min = KColor(1.0, 0.9, 0.5, 0.8),
Max = KColor(1.0, 1.0, 1.0, 1.0)
}
sparkles.GravityModifier = { Min = -0.05, Max = -0.02 }
sparkles.ForceOverLifetime.Enabled = true
sparkles.ForceOverLifetime.Keys = {
{ Time = 0, Value = Vector(0, 0) },
{ Time = 0.5, Value = Vector(0.03, 0) },
{ Time = 1, Value = Vector(-0.03, 0) }
}
sparkles.ColorOverLifetime.Enabled = true
sparkles.ColorOverLifetime.Gradient.AlphaKeys = {
{ Time = 0, Value = 0 },
{ Time = 0.2, Value = 1 },
{ Time = 1, Value = 0 }
}
sparkles:FollowEntity(player, Vector(0, -10))
end)2026-11-22.20-37-42.mp4
- Palette API
- Particle Emitter API
- AlignToVelocity API
- ColorBySpeed API
- ColorOverLifetime API
- ForceOverLifetime API
- InheritVelocity API
- Keyframe API
- LimitVelocityOverLifetime API
- Noise API
- PaletteBurst API
- PaletteGradient API
- PaletteOverLifetime API
- RotationBySpeed API
- ScaleBySpeed API
- Shape API
- SpriteSheet API
- SubEmitterOptions API
- VelocityOverLifetime API