Time slicing
Spread big jobs over several frames.
Some work is too big for one frame: 200 enemies re-pathing at once, rebuilding a navmesh, generating a chunk. Doing it all on the same frame causes a spike. Time slicing puts the work in a queue and does a fixed amount, or a fixed number of milliseconds, each frame.
Try this: Press Wake: 60 sleeping slimes all plan a path to you in one frame and the game freezes. Switch to Sliced and wake them again: they wake in a wave, no freeze.
Press Wake (Space) and watch the frame.
Prompt bit
Works for 2D or 3D in any engine (Unity, Unreal, Godot, web). Paste the short one for a quick fix, or the detailed one when you want it done properly.
Time-slice heavy work: queue requests such as pathfinding, process jobs each frame until 0.002 s has passed, serve nearby or visible agents first, and let waiting agents keep their old path instead of freezing until their new result arrives.
Add time slicing for expensive per-agent work (2D or 3D, any engine). Create a job queue for requests such as pathfinding, line-of-sight checks, AI decisions, or procedural generation. Each frame, pop and process jobs until a budget is spent (measure with a high-resolution timer, default 2 ms) or a max count is reached. Order by priority: visible, near the player, or waiting longest. Make long single jobs resumable (A* that continues next frame). Agents keep their previous plan until the new one arrives. Spread periodic updates across frames by giving each agent an offset (agent i updates when frame % N == i % N). For truly parallel work use the job system or worker threads, but slicing still controls integration on the main thread.
Where it's used
- RTS and crowds: hundreds of path requests
- Open worlds: streaming and generation
- Simulation games: many agents thinking
- Stealth games: staggered visibility checks
- Mobile games: keeping spikes off weaker CPUs
Common mistakes
Doing all requests on the frame they are made, slicing by count when jobs vary in cost, agents frozen while waiting for results, starving low-priority jobs forever, and every agent updating on the same frame.
Writing this with an AI assistant? See our best AI coding assistants for game developers.
Missing a concept? Request one.



