Make a Treasure Chest Shine in Rive: Light Rays, Glow and Gold Dust

In the last tutorial we made this chest open with squash and stretch and a Solo swap. It opens nicely, but nothing comes out of it. And a treasure chest with no light coming out of it and no gold flying out isn't really a treasure chest.
So in this one we add both.
There are four layers here, and they are built two different ways. The flash, the glow and the light rays are classic Keyframe animation in a State Machine. The gold dust is a script that the AI agent writes for us. Each layer is small on its own. Together they make the opening moment feel like a reward.
We start from the chest from part 1, already opening and closing on tap, with none of the light.
1. The flash when it opens
The first layer lasts less than half a second: a soft burst of light right at the moment the lid opens.
On the Chest Artboard, draw an Ellipse above the opening, 260 by 90, at about x 563, y 728. Give it the color FFF8D6 at 90%, a Feather of 70 so it has no hard edge, and set its Blend Mode to Screen, so it brightens whatever is under it instead of covering it. Then set its opacity to 0, so it is hidden until we need it.
In the Open timeline:
- Frame 6: opacity 0, Scale 100%
- Frame 10: opacity 100%
- Frame 11: Scale 125%
- Frame 24: Scale 100%
- Frame 26: opacity 0
It appears fast, grows a little, and fades out. In the Close timeline, key its opacity at 0 on frame 0, so closing the chest never shows it.
2. A glow that breathes over the gold
The flash is a one-time moment. The glow stays for as long as the chest is open.
Copy the flash Ellipse and paste it into the Chest Open Artboard, just above the coins, at about x 325, y 335. Change only three things: the size to 360 by 80, the color to FFCD2E at 70%, and the Feather to 50.
Now make it breathe. Give it its own timeline, set to loop, on its own Layer in the State Machine:
- Frame 0: opacity 75%, Scale 100%
- Frame 80: opacity 100%, Scale 108%
- Frame 160: opacity 75%, Scale 100%
Because it lives inside the open chest, it only shows when the chest is open, and it keeps going on its own.
3. Light rays that pour out of the opening
This is the layer that does most of the work.
Stay in Chest Open and put the rays on the top layer. Draw a Triangle, 450 wide and 760 tall, and flip it so the point faces down. Move it so the point sits below the coins, hidden under the rim, at about x 370, y 580. The point should never show: by the time the triangle reaches the opening, it is already wide.
Fill it with a Linear Gradient from FAD850 at 50% to FFDA49 at 0%, so the light is strongest near the gold and fades out as it rises. A Feather of 3.4 softens the edges just a little.
Then duplicate it three times and rotate the triangles into a fan: two to the left, two to the right. Each triangle goes into its own Group, Ray 1 to Ray 4, and each Group's Origin moves to the triangle's point. That's the point the ray will swing from. If the fan looks too even, change the Scale X of one triangle a little.
4. A mask so the light comes out of the chest
Right now the rays cover the front of the chest. We want them to start at the opening.
With the Pen tool, draw a shape right on the chest: along the inner rim of the box, then up and around all the rays. Name it Hole mask. Select the four rays, add Clipping, and pick Hole mask. Now the light comes out of the whole opening, and the points of the triangles are hidden inside the box.
Rive Masterclass + Rive Scripting
Master Rive for real products.
Get Both for $219Both courses for $219. Save $49.
5. The sway
Still rays look like a sticker. A slow sway makes them feel like light.
Animate the Groups, not the triangles, and only their rotation. One timeline called Rays for all four, 120 frames long, set to loop, with Cubic easing, on its own Layer in the State Machine.
- Ray 1: -4° at frame 0, 4° at frame 60, -4° at frame 120
- Ray 2: the opposite, 4°, -4°, 4°
Neighboring rays swing in opposite directions, so they slide over each other. Where they overlap, the light gets brighter, and that moving overlap is most of the effect.
6. The offset
If all four rays move on the same beat, it looks mechanical. So rays 3 and 4 get the same motion, shifted 30 frames, a quarter of the loop.
- Ray 3 (Ray 1 shifted): 0° at frame 0, -4° at 30, 4° at 90, 0° at 120
- Ray 4 (Ray 2 shifted): 0° at frame 0, 4° at 30, -4° at 90, 0° at 120
Copy the Keyframes from ray 1, move them 30 frames, and make the slopes match so the loop stays smooth. It's the same offset idea as in my bouncing ball Short.
Play it and tap: the chest opens with a flash, the glow breathes, and the rays sway one after another, never together.
7. Gold dust, written by the AI agent
The last layer is the one that makes the chest feel alive: small gold specks that burst out when it opens and keep floating up while it stays open.
You could build this with Keyframes, but each speck would need its own path, its own timing and its own fade. That's exactly the kind of thing a script is good at, so this part is a script.
On the Chest Artboard, open the AI agent and describe the effect: what the specks look like, how they move, how they twinkle and fade, what happens when the chest opens and closes, and which values you want to control. I describe what I want to see, not how to code it.
The agent writes the script and gives you inputs. I set them to:
- Burst count: 40
- Specks per second while open: 3
- Start point: 563, 745
- Spread: 185
If it doesn't connect the dust to the chest on its own, one more sentence asking it to fire the burst when the lid opens and stop when it closes does it.
What we built
The chest went from one that only opens and closes to one with a flash, a breathing glow, four swaying light rays and gold dust. You can push each layer further, or add more layers to make the opening even bigger. This is the base.
Go further
The flash, the glow, the rays and the offset are Keyframes and State Machines, which I teach step by step in the Rive Masterclass. We build an interactive weather app from scratch and connect it to real data with Data Binding.
The gold dust is a script I made with the AI agent and the Rive MCP in Claude. If you want to go deeper into scripting with the agent, that's the Rive Scripting course, where we build a full interactive space game.
Missed part 1? This is where the chest learns to open:
Get more Rive tips
Weekly tutorials, new lessons, and Rive community highlights — no spam.


