0
0
Unityframework~3 mins

Why Color and size over lifetime in Unity? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if your particles could magically change color and size all by themselves, making your game look amazing?

The Scenario

Imagine you want to create a firework effect in a game where sparks change color and size as they fade away. Doing this by hand means adjusting each spark's color and size frame by frame.

The Problem

Manually changing color and size for every particle over time is slow and tiring. It's easy to make mistakes, and the effect won't look smooth or natural.

The Solution

Using "Color and size over lifetime" lets you set rules that automatically change these properties as particles live and die. This makes effects look smooth and saves lots of time.

Before vs After
Before
for each particle:
  if age < 1s:
    color = red
    size = 1
  else:
    color = black
    size = 0.1
After
particleSystem.colorOverLifetime.enabled = true;
particleSystem.colorOverLifetime.color = gradientRedToBlack;
particleSystem.sizeOverLifetime.enabled = true;
particleSystem.sizeOverLifetime.size = curveFrom1To0.1;
What It Enables

You can create beautiful, dynamic effects that change naturally over time without writing complex code.

Real Life Example

Think of a magic spell in a game where glowing orbs start bright and big, then slowly shrink and fade to nothing as they disappear.

Key Takeaways

Manually changing particle color and size is slow and error-prone.

Color and size over lifetime automate smooth transitions.

This makes creating realistic effects easy and fast.