Smooth camera follow
A 2D camera that glides after the player instead of being glued to them. It ignores small steps, looks ahead in the direction of travel, and stops at the edges of the level.
When you need it
For any game where the world is bigger than the screen: platformers, top-down adventures, racing games. It is what makes movement feel calm instead of nervous.
Say this to your AI
Use the smooth camera from Spielerando so the view glides after my character, looks ahead when running, and never shows anything outside the level.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP
Settings
- halfLife (0.15): Seconds to close half the gap to the player. Small is tight, big is floaty.
- deadZoneWidth (64): How wide the box is that the player can move in before the camera reacts.
- deadZoneHeight (48): The same in height. Keep it tall enough that a jump does not move the camera.
- lookAhead (0.25): How many seconds of travel the camera looks ahead, so the player sees what is coming.
- lookAheadHalfLife (0.3): How softly the view turns round when the player does.
Your AI gets the code
The finished code and math come through the Spielerando connection, so your AI can use them right away. Connect your AI
Common questions
how do i make a smooth camera in my game
Do not copy the player's position to the camera. Let the camera close part of the gap each moment, and let the player move in a small box before the camera reacts at all.
why does my camera feel jittery
Usually the camera follows every tiny movement, or it moves a fixed amount per frame. A small box where nothing happens removes the first problem, and basing the glide on time removes the second.
how do i stop the camera at the edge of the level
After moving the camera, hold its centre at least half a screen away from each edge. If the level is smaller than the screen, keep the camera in the middle.