0
0
Unityframework~15 mins

Color and size over lifetime in Unity - Deep Dive

Choose your learning style9 modes available
Overview - Color and size over lifetime
What is it?
Color and size over lifetime is a way to change how a particle looks as it lives in a particle system. It means the particle can start one color or size and slowly change to another before disappearing. This helps make effects like fire, smoke, or magic look more natural and interesting. It is done by setting curves or gradients that control color and size from birth to death of each particle.
Why it matters
Without changing color and size over lifetime, particles would look flat and unrealistic. Effects would feel static and boring, losing the magic of movement and change. This concept lets creators tell stories with visuals that evolve, like sparks fading or bubbles growing. It makes games and animations feel alive and engaging, improving player experience and immersion.
Where it fits
Before learning this, you should understand basic particle systems in Unity, including how to create and emit particles. After mastering color and size over lifetime, you can explore more advanced particle features like velocity over lifetime, custom shaders for particles, and combining multiple modules for complex effects.
Mental Model
Core Idea
Particles can smoothly change their color and size from birth to death using curves and gradients that define their life journey.
Think of it like...
It's like watching a flower bloom and then wilt: it starts small and green, grows bigger and colorful, then fades away. The particle changes similarly over its lifetime.
Particle Lifetime ──────────────▶
┌───────────────┐  ┌───────────────┐
│ Start (birth) │  │ End (death)   │
└──────┬────────┘  └──────┬────────┘
       │                  │
       │ Color & Size     │
       │ change gradually │
       ▼                  ▼
  Small, bright       Large, faded
  or initial color    or final color
Build-Up - 7 Steps
1
FoundationUnderstanding Particle Lifetime Basics
🤔
Concept: Particles have a lifetime during which they exist and can change properties.
In Unity, each particle has a lifetime measured in seconds. When a particle is created, its lifetime starts at zero and counts up until it reaches its maximum lifetime, then the particle disappears. This lifetime is the timeline for any changes in color or size.
Result
You know that lifetime is the time window to apply changes to particles.
Understanding lifetime as a timeline is key to controlling how particles evolve visually.
2
FoundationUsing Color Over Lifetime Module
🤔
Concept: Unity lets you assign a color gradient that changes particle color over its lifetime.
In the Particle System component, enable 'Color over Lifetime'. You can then set a gradient with colors at different points from 0 (birth) to 1 (death). Unity interpolates colors smoothly as the particle ages.
Result
Particles smoothly shift colors as they live, for example from bright yellow to transparent red.
Color gradients let you create natural fading or color-shifting effects without manual animation.
3
IntermediateUsing Size Over Lifetime Module
🤔
Concept: You can also change particle size over lifetime using a curve that defines size scale from birth to death.
Enable 'Size over Lifetime' in the Particle System. Set a curve where the x-axis is lifetime (0 to 1) and y-axis is size multiplier. For example, start small (0.1), grow to full size (1), then shrink to zero.
Result
Particles grow or shrink smoothly during their lifetime, adding dynamic motion.
Size curves add depth and realism by simulating growth or fading away of particles.
4
IntermediateCombining Color and Size Changes
🤔Before reading on: do you think color and size changes happen independently or affect each other? Commit to your answer.
Concept: Color and size over lifetime modules work independently but combine visually to create complex effects.
You can enable both modules at once. Unity applies color and size changes simultaneously based on the particle's lifetime. For example, a particle can grow bigger while fading out in color.
Result
Particles show combined visual changes, making effects richer and more natural.
Knowing these modules combine lets you design layered effects without extra coding.
5
IntermediateEditing Curves and Gradients Precisely
🤔
Concept: You can customize curves and gradients with multiple points for detailed control over changes.
In the editor, add multiple keys to the size curve or color gradient. Each key sets a value at a specific lifetime fraction. This lets you create effects like pulsing size or color flickers by adjusting curve shapes and gradient stops.
Result
Particles can have complex, non-linear changes over lifetime.
Mastering curve editing unlocks fine-tuned control for professional-quality effects.
6
AdvancedUsing Randomness with Over Lifetime Modules
🤔Before reading on: do you think all particles share the exact same color and size changes or can they vary? Commit to your answer.
Concept: Unity allows randomness in color and size changes to make particles less uniform and more natural.
You can add randomness by using multiple gradients or curves with random seeds, or by enabling 'Separate Axes' for size to vary width and height independently. This randomness means each particle changes slightly differently.
Result
Particle systems look more organic and less artificial.
Random variation prevents mechanical repetition, enhancing realism in effects.
7
ExpertPerformance and Precision Trade-offs
🤔Before reading on: do you think very complex curves and gradients affect game performance? Commit to your answer.
Concept: Complex curves and gradients increase GPU and CPU work, affecting performance especially on many particles.
Using many keys in curves or gradients requires more calculations per particle. On low-end devices or large particle counts, this can reduce frame rates. Experts balance visual quality with performance by simplifying curves or using baked textures for color changes.
Result
You can optimize particle effects to run smoothly without losing visual appeal.
Understanding performance impact guides smart design choices in production.
Under the Hood
Unity's particle system calculates each particle's age as a fraction of its lifetime (0 to 1). It then evaluates the color gradient and size curve at that fraction to determine the particle's current color and size. These values are passed to the GPU for rendering each frame. The interpolation between keys in gradients and curves is done using linear or smooth interpolation algorithms.
Why designed this way?
This design allows artists to intuitively control particle appearance over time without coding. Using normalized lifetime (0 to 1) makes curves and gradients reusable regardless of particle lifetime length. Interpolation provides smooth transitions, avoiding abrupt changes that look unnatural.
┌───────────────┐
│ Particle Age  │
│ (0 to 1)      │
└──────┬────────┘
       │
       ▼
┌───────────────┐       ┌───────────────┐
│ Evaluate      │──────▶│ Color Gradient│
│ Size Curve    │       └───────────────┘
└──────┬────────┘
       │
       ▼
┌───────────────┐
│ Current Color │
│ Current Size  │
└──────┬────────┘
       │
       ▼
┌───────────────┐
│ GPU Renderer  │
│ Draw Particle │
└───────────────┘
Myth Busters - 4 Common Misconceptions
Quick: Do particles keep their initial color and size if you disable over lifetime modules? Commit yes or no.
Common Belief:If you disable color and size over lifetime, particles keep their initial color and size unchanged.
Tap to reveal reality
Reality:Particles keep their initial color and size only if those properties are set in the main module. Over lifetime modules override these properties dynamically.
Why it matters:Confusing this can cause unexpected particle appearance, making debugging effects harder.
Quick: Do you think color and size changes happen instantly at key points or smoothly over time? Commit your answer.
Common Belief:Color and size jump instantly at the points defined in curves or gradients.
Tap to reveal reality
Reality:Unity interpolates smoothly between keys, so changes happen gradually over the particle's lifetime.
Why it matters:Expecting jumps leads to wrong curve editing and unnatural effects.
Quick: Do you think all particles in a system share the exact same color and size changes? Commit yes or no.
Common Belief:All particles follow the exact same color and size curves without variation.
Tap to reveal reality
Reality:Particles can have random variations in these properties, making effects more natural.
Why it matters:Ignoring randomness leads to repetitive, artificial-looking effects.
Quick: Do you think very complex curves have no impact on game performance? Commit yes or no.
Common Belief:Complex color and size curves do not affect performance because GPUs are fast.
Tap to reveal reality
Reality:Complex curves increase computation per particle and can reduce performance on many particles or low-end devices.
Why it matters:Not considering performance can cause frame drops and poor user experience.
Expert Zone
1
Size over lifetime can use separate curves for width and height, allowing non-uniform scaling that adds realism.
2
Color over lifetime supports alpha channel changes independently, enabling particles to fade out smoothly without changing color hue.
3
Random seeds in particle systems affect how over lifetime modules apply randomness, so controlling seeds can reproduce or vary effects precisely.
When NOT to use
Avoid using complex color and size over lifetime curves for very large particle counts on low-end hardware; instead, use simpler curves or pre-baked animated textures. For effects needing precise control per particle, consider custom shaders or GPU particle systems.
Production Patterns
In production, artists combine color and size over lifetime with velocity and rotation modules to create natural effects like smoke that grows and fades, or sparks that brighten then dim. Developers optimize by limiting curve complexity and using LOD (level of detail) systems to reduce particle counts on weaker devices.
Connections
Animation Curves
Color and size over lifetime use animation curves to define changes over time.
Understanding animation curves in general helps grasp how particle properties evolve smoothly and can be reused in other Unity animations.
Shader Programming
Shaders can also control particle color and size dynamically, sometimes replacing over lifetime modules for more complex effects.
Knowing how shaders work lets you extend or optimize particle appearance beyond built-in modules.
Biological Growth Processes
The way particles change size and color over lifetime mimics natural growth and decay in biology.
Recognizing this connection helps design more believable effects by applying natural patterns of change.
Common Pitfalls
#1Particles do not change color or size as expected.
Wrong approach:ParticleSystem.colorOverLifetime.enabled = false; ParticleSystem.sizeOverLifetime.enabled = false;
Correct approach:ParticleSystem.colorOverLifetime.enabled = true; ParticleSystem.sizeOverLifetime.enabled = true; // Then set gradients and curves properly
Root cause:Disabling the modules means no over lifetime changes happen; forgetting to enable them causes no visible effect.
#2Particles change size abruptly instead of smoothly.
Wrong approach:Set size curve with only two keys at 0 and 1 with very different values and no interpolation.
Correct approach:Add intermediate keys and use smooth tangents in the size curve editor for gradual size changes.
Root cause:Using linear or step interpolation without intermediate keys causes sudden jumps.
#3All particles look identical and artificial.
Wrong approach:Use single gradient and curve without randomness or variation settings.
Correct approach:Enable randomness in size and color modules or use multiple gradients/curves with random seeds.
Root cause:Ignoring randomness leads to uniform particle behavior.
Key Takeaways
Color and size over lifetime let particles smoothly change appearance from birth to death using gradients and curves.
These modules work on a normalized lifetime scale from 0 to 1, making changes independent of actual particle lifetime length.
Combining color and size changes creates richer, more natural particle effects without extra coding.
Randomness in these changes prevents repetitive patterns and enhances realism.
Complex curves improve visuals but can impact performance, so balance detail with efficiency.