Floating Coin Collectibles with Independent Animation in Unreal Engine

In this project, I designed a field of floating coin collectibles that each animate and rotate on their own, without relying on a central manager. By moving the animation logic into each coin’s Blueprint and adding a simple rotation node, I achieved precise, beat-synced motion and greater flexibility for future tweaks.

From Central Manager to Per-Coin Control

Initially, I tried driving all coins from a single “Coin Manager” Blueprint, looping through every instance and triggering their timelines via modulo arithmetic. However, only one coin (the last one placed) would animate correctly, and splitting the branch logic made it even less reliable.

To solve this, I moved the animation entirely into each BP_Coin Blueprint:

  • Rotation Node: A constant “Add Local Rotation” node spins each coin around its vertical axis.

  • Timeline for Vertical Sway: Each coin holds its own Timeline with a float track that drives a simple up-and-down offset via SetRelativeLocation.

This per-coin approach avoids timing conflicts, ensures every coin animates identically, and lets me tweak individual coins without touching a global manager.

Blueprint Animation Breakdown

1. Rotation

  • Add Local Rotation: Ticks every frame, rotating the Static Mesh component by a small delta (e.g., 60°/s).

  • Benefit: No Timeline needed for rotation; performance cost is minimal and spread across coins.

2. Vertical Sway Timeline

  • Timeline Asset:

    • Duration: 1 second

    • Float track “Sway”: goes from 0 → 1 → 0

  • On Update:

    • Remap “Sway” value to a vertical offset (e.g., −20 → +20 units).

    • Call SetRelativeLocation on the mesh.

  • Looping:

    • Timeline set to “Play from Start” on BeginPlay and set to loop.

Collection Logic

Each coin still reports back to game logic when collected, but without controlling animation:

  1. OnComponentBeginOverlap

  2. Cast to Player Character

  3. Trigger Collection Event (sound, score increment)

  4. Set Visiblity (Could also Destroy Actor)

Because the overlap and destruction occur entirely within the coin Blueprint, there’s no need for the manager to handle playback or recycling.

Beat-Synced Offset

To add visual interest, coins can bounce on alternating beats:

  • Array Index: Each coin reads its own ArrayIndex (assigned in level—e.g., 0, 1, 2, …).

  • Modulo Check: In BeginPlay, check ArrayIndex % 2 == 0.

    • Even coins start their sway Timeline immediately.

    • Odd coins wait half a period (0.5 s) before playing, creating an alternating rhythm.

This simple modulo trick yields a pulsating wave of coins without a manager.

Performance & Scalability

  • Decentralized Logic: Coin Blueprints handle their own animation and collection.

  • Minimal Overhead: Rotation node runs in native C++; Timeline only updates a single float per coin.

  • Level Design: Placing dozens of coins remains smooth at 60 fps on target hardware.

For very large numbers of coins, you could batch animations into GPU shaders or use instanced meshes—but for typical collectible counts (20–50), this Blueprint-only solution is both clear and performant.

Previous
Previous

Shop System

Next
Next

Hedge Cannon