Make a looping animation repeat without a hitch, also backwards
Clouds, spinning coins and bobbing lanterns glitch at the seam, run wrong when time goes negative, or start to jitter after the game has been open for hours. Here is how to turn a growing clock into a clean repeating position, including the back-and-forth kind.
Why this works
A loop is a clock that goes round, so the position is the remainder after whole laps. The usual remainder breaks below zero, and a clock that only ever grows loses its fine steps, so keep the position inside one lap and count the laps on the side.
When not to use it
Don't use it when the end should not look like the start, such as a character who ages, a day that changes the weather, or a one-time intro. A loop hides progress. Use a timeline that moves forward, or change something on each lap.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 4 common mistakes and the fix
- 29 lines of example code with 5 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Make a looping animation repeat without a hitch, also backwards" (read_entry looping-animation-time-wraps-without-a-hitch) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP