Skip to content
AI-powered appsNewChat, vision, voice, generationBookings & schedulingAppointments that book themselvesShops & sellingA storefront in every pocketClient & businessRun the operation from one placeCommunities & clubsA home that is not a group chat
Health & wellnessHabits, tracking and calmGames2D, 3D and multiplayerPersonal & toolsThe tool you wish existedInternal toolsThe tool ops never had time for
See all use cases
ArcadeNewPricingSecurity
EngineThe game engine and World EditorHow it worksFrom one sentence to a live productDocsGuides for building and publishingBlogStories, guides and newsChangelogWhat shipped latelyStatusUptime of every serviceSupportGet help from the team
AI-powered appsBookings & schedulingShops & sellingClient & businessCommunities & clubsHealth & wellnessGamesPersonal & toolsInternal tools
See all use cases
ArcadeNewPricingSecurity
EngineHow it worksDocsBlogChangelogStatusSupport
Language
Blog
Game mechanicsNovember 22, 20266 min read

Smooth 8-Direction Top-Down Movement

Top-down movement looks like four lines of code. The difference between stiff and smooth is in diagonals, acceleration, walls and which way the character faces.

Startbase Team
Editorial ink illustration of a brass eight-point compass rose with a small beetle walking off a diagonal, the needle in ember orange

Key takeaways

  • Normalize the input vector so diagonals are not 41 percent faster, then multiply by speed. It is the most common top-down bug.
  • Reach top speed in about 0.06 to 0.12 seconds and stop slightly faster. Snappy acceleration reads as control; slow acceleration reads as ice.
  • Resolve collisions one axis at a time so the character slides along walls, and nudge it around corners by a few pixels.

Smooth top-down movement needs four things: an input vector normalized so diagonals are not faster, short acceleration and deceleration so the character starts and stops crisply, collision resolved one axis at a time so it slides along walls instead of sticking, and a facing direction that stays put when the player lets go. Add a radial dead zone for analog sticks and a few pixels of corner nudging, and an 8-direction character feels good on keyboard, gamepad and touch.

The diagonal bug

The first version of top-down movement usually reads keys into x and y (each -1, 0 or 1) and multiplies both by speed. Moving diagonally then covers `√2 ≈ 1.41` times the distance per second: 41 percent faster. Players notice immediately, and speedrunners exploit it. The fix is one line: if the input vector is longer than 1, normalize it.

  • Keyboard: build the vector from keys, normalize when both axes are pressed.
  • Analog stick: clamp the vector length to 1 rather than normalizing, so a half-tilted stick still means half speed.
  • Touch virtual stick: treat it like an analog stick, with the finger's distance from the stick center (clamped to its radius) as magnitude.

Speed and acceleration

  • Speed: 3 to 5 tiles per second is a common feel for action games (about 150 to 250 px/s with 48 pixel tiles). Cozy and exploration games sit at 2.5 to 3.5; arcade shooters can go higher.
  • Acceleration time: 0.06 to 0.12 seconds from standing to top speed. Use `velocity = moveTowards(velocity, input × speed, accel × dt)` so direction changes also accelerate.
  • Deceleration time: a bit shorter, 0.04 to 0.08 seconds. Stopping on a dime is what makes dodging feel precise.
  • Turning: let velocity swing toward the new direction at the same acceleration. Instant 180 degree turns feel twitchy on gamepads but fine on keyboards; a turn rate slightly higher than acceleration is a good middle.
  • Slippery surfaces (ice, mud) are just lower acceleration values for that terrain, which makes them easy to add later.

Tip

Always multiply by frame time. Movement written as "add 4 pixels per frame" runs twice as fast on 120 Hz phones as on 60 Hz laptops, and that difference will show up in every playtest.

Dead zones for sticks

Analog sticks and virtual touch sticks never rest at exactly zero. Without a dead zone, the character drifts. Use a radial dead zone (based on the vector's length) rather than separate per-axis dead zones, which snap diagonal input toward the axes and make 8-direction movement feel like 4-direction movement.

  • Gamepad dead zone: about 0.15 to 0.2 of the stick radius. Rescale the remaining range to 0 to 1 so movement starts smoothly just outside the dead zone.
  • Touch stick dead zone: about 10 to 15 percent of its radius, with the stick base placed where the finger first lands (a floating stick). Our touch controls guide has the details.
  • Optional 8-way snapping: for pixel art games with only 8 sprite directions, snap the movement angle to the nearest 45 degrees. Movement then matches the art exactly, at the cost of some analog freedom.

Sliding along walls

Push diagonally into a wall and the character should slide along it, not stop dead. The simplest reliable approach for tile-based or box-based worlds: move on the x axis, resolve collisions, then move on the y axis and resolve again. Blocked on one axis, the other still moves. Physics engines do this for you with their contact solver, but a custom approach is usually more predictable for characters.

  • Corner nudging. When the character is blocked by the corner of a wall by only a few pixels (4 to 8 at 720p), shift it sideways around the corner instead of stopping it. Doorways become easy to enter, which players notice only when it is missing.
  • Rounded hitbox. A circle or a box with rounded corners slides around edges more naturally than a sharp box.
  • Hitbox at the feet. In top-down games with some perspective, the collision shape should cover the character's feet, about the lower third of the sprite. Using the full sprite box makes characters bump their heads on walls they are standing in front of.

Facing and animation

  • Keep the last facing when idle. When input stops, the character keeps facing the direction it last moved. Resetting to "down" is a classic bug.
  • Do not change facing on very brief diagonal input when releasing two keys a frame apart. Ignore facing changes shorter than about 0.05 seconds, or the character snaps to a diagonal every time it stops.
  • Choose 4 or 8 sprite directions. Four directions with horizontal flipping is cheap: pick the axis with the larger input. Eight directions look smoother but need more art; our pixel art guide covers the cost.
  • Walk cycle speed follows velocity. Scale animation speed with actual movement speed so feet do not slide during acceleration.
  • Aim separate from movement. In shooters, facing follows the aim, and the walk cycle may play backwards when moving away from it. See the top-down shooter guide for aiming schemes.

Depth sorting and pixel jitter

In top-down games with a bit of perspective (characters standing in front of or behind trees), draw everything sorted by the y position of its feet, so the character goes behind a tree when walking above it. Sort every frame, or only when things move. For pixel art, round the draw position to whole pixels but keep the real position as a float: rounding the real position makes slow diagonal movement stutter, because the character moves on one axis one frame and the other the next.

How it combines with other mechanics

A dash or dodge is a short override of velocity, after which normal acceleration takes back over. Stamina can gate running. Knockback replaces velocity for a fraction of a second. Farming and life sims add interaction targeting: the tile in front of the facing direction is the one the player acts on, which is why facing has to be reliable; our farming game guide relies on it. Some games mix free movement with a grid, snapping to grid-based movement indoors or for puzzle rooms.

A brief to paste

Make my top-down character movement feel smooth in 8 directions. Speed 200 px/s. Normalize keyboard input and clamp stick input to length 1. Reach top speed in 0.08 s and stop in 0.05 s using move-towards on velocity, with frame time. Radial dead zone 0.18 on gamepads; floating touch stick with a 12 percent dead zone. Move and resolve collisions on x, then on y, so the hero slides along walls, with a rounded hitbox covering the lower third of the sprite and a 6 px corner nudge around wall corners. Keep the last facing when idle and ignore facing changes shorter than 0.05 s. Walk animation speed follows actual speed. Sort sprites by feet y. Round draw positions to whole pixels but keep the real position as a float. Expose speed, acceleration, deceleration, dead zone and nudge as dials.

On Startbase, those dials appear in the engine panel while the game runs (games template docs). Try the movement on a gamepad, a keyboard and a phone before changing the numbers: they feel different on each, and the best values are the ones that hold up on all three.

Frequently asked questions

Why is my character faster moving diagonally?

Combining full x and y input makes a vector about 1.41 long. Normalize keyboard input (or clamp stick input to length 1) before multiplying by speed.

How do I stop my character from sticking to walls?

Resolve movement one axis at a time: move on x and fix collisions, then move on y and fix collisions. Add a small corner nudge so the character slips around wall corners and into doorways.

How fast should a top-down character move?

A common range is 3 to 5 tiles per second for action games and around 2.5 to 3.5 for cozy exploration games, reaching top speed in about a tenth of a second.

On this page

  • The diagonal bug
  • Speed and acceleration
  • Dead zones for sticks
  • Sliding along walls
  • Facing and animation
  • Depth sorting and pixel jitter
  • How it combines with other mechanics
  • A brief to paste

Keep reading

More in Game mechanics
Editorial ink illustration of a wooden toy figure in mid-air above a gap, the puff cloud under its feet in ember orange
Game mechanicsNovember 22, 2026

How to Add a Double Jump to Your Game

A double jump is one counter and one reset rule, but the details decide whether it feels like control or like cheating. Here are the values and the bugs to watch for.

8 min read
Editorial ink illustration of a small figure streaking along a stone floor with faded ghost copies behind it, the front figure's scarf in ember orange
Game mechanicsNovember 22, 2026

How to Add a Dash Move

A dash is a short burst of fixed speed that overrides normal movement. Get its distance, its ending and its refill rule right and it becomes the move players use most.

7 min read

Read less. Ship more.

Everything in this post is one prompt away. Describe your app and watch it build.

Start building

Apps, games, backends and publishing from one conversation.

Product

  • Features
  • Use cases
  • Pricing
  • Changelog

Resources

  • Blog
  • Docs
  • Support
  • Status
  • Security

Contact

  • w@startbase.ai
  • X / Twitter
  • LinkedIn
  • Instagram

Legal

  • Terms
  • Privacy

© 2026 Startbase. All rights reserved.