
Scripting
Building a Fully Dynamic Particle System in Rive with Scripting & AI Agent
Dec 23, 2025
|
10
min read
Full Video Tutorial
Rive gives designers a high level of control over interactive animation, especially through state machines and real-time behavior.
Because Rive is intentionally lightweight and built around dynamic, real-time systems, it doesn’t rely on plugins or preset effect libraries.
As a result, effects that are often plug-and-play in other tools - such as particle systems for confetti, sparks, or snow - are approached differently in Rive. Their behavior is defined explicitly: how many elements exist, how they move, and how they evolve over time.
Until recently, achieving this kind of behavior required a fair amount of manual setup and offered limited flexibility once in place.
With the introduction of scripting and the AI Agent, this approach becomes practical, scalable, and truly dynamic.
This article walks through how a fully dynamic, reusable particle system can be built from scratch in Rive - using scripting to manage behavior and reuse.
The Mental Model
Before writing any code, it’s important to reframe how particles work in Rive.
Artboard = Particle
Script = Particle System
Each particle is represented by a small Artboard - a visual prefab.
The script doesn’t draw shapes - it creates, positions, moves, and recycles Artboard instances.
This separation gives us:
Visual control in Design Mode
Behavioral control in Scripting
A system that’s easy to extend later
Once this mental model clicks, everything else becomes much simpler.
Creating the Particle Artboard
We start by creating a tiny Artboard that represents a single snowflake.
Size: 24×24
Simple white ellipse
Origin centered
Defined as a Component
This Artboard has no logic, no animation, and no awareness of the system - that’s intentional.
Using an Artboard for each particle lets us swap the visual later - snowflakes, raindrops, stars, or any other shape - without touching the script at all.
Introducing the Script
We then create a Node Script, which acts as the system’s control layer.
The script is responsible for:
Spawning particles
Updating their position every frame
Applying speed, wind, scale, and parallax
Recycling particles when they leave the screen
The particle is passed into the script as an Artboard input.
This is a key design choice: the script doesn’t care what the particle looks like - only how it behaves.
At this stage, we define the minimal input needed to keep the system fully decoupled from the particle’s visual design.
Working with the Rive AI Agent
One of the most important parts of this process wasn’t just scripting - it was how the scripting was built.
Instead of writing the entire system upfront, the Rive AI Agent was used to iterate on the logic step by step.
The Agent was especially useful for:
Adding one behavior at a time (falling, looping, wind, scale, parallax)
Modifying existing logic without breaking the system
Refining math and edge cases quickly
Keeping the code readable and intentional
Rather than “generate everything”, the Agent acted like a pair programmer.
The system was built by describing each next step, testing it visually, and layering complexity gradually - exactly how motion is typically designed.
The Agent doesn’t replace understanding. It accelerates iteration.
Drawing and Updating a Single Particle
Before creating a full system, we start by drawing one particle. We:
Advance the animation by using the advance() function
Draw the particle Artboard in the draw() function, update it every frame
At this stage, nothing moves yet. This confirms:
The script is connected
The Artboard input works
The render loop is correct
Building incrementally avoids debugging complex systems too early.
Making the System Screen-Aware
To keep the system reusable, the script needs to be aware of the screen size. We expose these inputs:
screenWidth
screenHeight
This allows the system to:
Spawn particles correctly
Loop them outside screen bounds
Adapt to different layouts
Later, these values can be bound to a ViewModel instead of being hardcoded.
Before adding complexity, we verify that the rendering loop and Artboard input behave as expected.
Falling Motion and Seamless Looping
Now we introduce the core behavior: particles fall from above the screen to below it, then loop seamlessly.
Key rules:
Particles start outside the visible area
They move downward over time
Once they fully exit the bottom, they respawn at the top
This prevents visible popping and creates a seamless, infinite loop.
Scaling Up with Particle Count
A single falling particle doesn’t yet form a system. We introduce particlesCount and let the script:
Spawn multiple particles
Randomize their starting X and Y positions
Stagger their timing
Each particle behaves independently, but follows the same system rules.
This is the moment where we move from an animation to a particle system.
Speed as a System Control
Next, we add speedFactor. It behaves exactly like scaling a timeline:
1 → normal speed
2 → twice as fast
0.5 → half speed
Speed affects the entire system uniformly, not individual particles.
Adding Wind
To make the motion feel more natural, we introduce wind. Instead of using raw angles, wind is normalized between -1 and 1:
-1 → Wind to the left
0 → No wind
1 → Wind to the right
This value is mapped to a small angle (±15°) and used for slight rotation and horizontal drift
Normalization keeps the system predictable and easy to bind to external data.
Expanding the Spawn Range
Once wind is applied, particles can drift sideways.
Instead of correcting positions with offsets, we expand the horizontal spawn range to about 120% of the screen width.
Particles can start slightly outside the screen and naturally drift into view.
This keeps the logic simple and avoids artificial corrections.
Size Variation with Scale Levels
Uniform particles feel artificial. We introduce scaleLevels - a discrete control (1–5) that defines how many size variants exist.
Examples:
1 → All particles same size
3 → Small / medium / large
5 → Full depth range
Each particle randomly selects from predefined size sets, creating controlled variation without chaos.
Depth with Parallax
With a boolean input, useParallax, we add depth.
Larger particles move slightly faster
Smaller particles move slightly slower
This creates a convincing sense of depth: near elements feel closer, far elements feel distant.
Parallax is optional - the system works without it.
Making the System Responsive with Data Binding
To make the particle system truly reusable, it needs to adapt to the size of the Artboard automatically.
We expose the screen width and height as inputs and bind them via Data Binding to a simple ViewModel representing the screen size.
Once bound, the system becomes fully responsive:
• Changing the Artboard size immediately updates the particle area
• Spawn positions and loop boundaries adjust automatically
• The same system works across different screen sizes without modification
At this point, the particle system is no longer tied to a fixed canvas - it becomes data-driven and layout-aware, ready for real product use.
One Script, Multiple Particle Systems
This is where the system really shines. Because:
The particle visual is an Artboard input
All behavior is driven by parameters
The logic is completely generic
The same script can be reused multiple times. In practice, this means:
One instance can drive background snow
Another can drive heavier foreground flakes
Another can control falling stars or decorative particles
Each instance:
Uses a different particle Artboard
Has different counts, speeds, and scale levels
And runs simultaneously on the same screen
You’re not building an effect. You’re building a system.
Why This Matters in Rive
The snow effect shown here is intentionally simple. Once the foundation exists, extending it becomes trivial:
Particles can move upward instead of downward
New parameters can be added to control behavior
Special effects and interactions can be layered on top
Each particle can become a complex animated element - not just an icon or an image
Because particles are Artboards, each one can include:
Its own animation
Internal state machines
Interaction logic
Nested components
This highlights one of Rive’s core strengths: you’re not limited to preset effects.
You’re building vector-based, dynamic, interactive systems designed specifically for your product and your use case.
Final Thoughts
This particle system is fully dynamic, flexible, customizable, and reusable.
By combining Rive’s scripting feature with the AI Agent, complex behavior can be built incrementally - without losing clarity or visual control.
One script. Many effects. A reusable foundation.
What's Next?
This particle system is a good example of how scripting unlocks entirely new workflows in Rive - moving from predefined effects to reusable, data-driven systems.
You can explore more about scripting, inputs, and advanced workflows in the official Rive documentation and community resources.
If you want to learn Rive step by step and see how these systems are built in real projects, you can explore the full course here: