02 · Movement · 2D and 3D

Diagonal movement normalization

Why holding two arrow keys makes characters 41% faster.

Right is (1, 0). Right plus up is (1, 1), and that vector is about 1.41 long, not 1. Multiply it by your speed and diagonal movement is 41% faster than straight movement. Players exploit it, and it makes top-down and 3D movement feel uneven. Clamping the input to length 1 fixes it.

←→↑↓ or WASD moveN fix on/offR raceDrag on the arena to move

Try this: Press R to race both to the far corner diagonally. Then turn the fix on with N and race again.

raw input (no fix)your moverspeed ring = intended top speed

Your speed 0%Straight speed is 100%

Move diagonally and watch your speed.

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.

Normalize movement input: build the direction from keys or stick and, if its length is above 1, divide by its length before multiplying by speed, so a 1 s diagonal run covers the same distance as a straight one; leave gentler analog pushes untouched.

44 words · one sentence to paste as is

Where it's used

Common mistakes

Always normalizing (a slight stick tilt then runs at full speed), normalizing a zero vector (divide by zero gives NaN and the character vanishes), and in 3D normalizing before flattening the camera direction so looking up or down changes speed.

Writing this with an AI assistant? See our best AI coding assistants for game developers.

Missing a concept? Request one.

Related concepts

New concepts, in your inbox.

One short email when we add new concepts, plus our weekly roundup of AI tools for game devs. Unsubscribe any time.