A Third-Person Character and Camera Controller
A third-person controller is two systems that have to agree: a character that moves where the stick points, and a camera that decides what "forward" means.

Key takeaways
- Move relative to the camera: flatten its forward direction onto the ground and build input from that, every frame.
- Use a kinematic capsule with step, slope and ground-snap settings, and reach top speed in about 0.1 to 0.2 seconds.
- Orbit at 4 to 6 meters with clamped pitch, pull in on collision fast and ease out slowly, and update the camera after physics with interpolation.
A third-person controller moves a character in a 3D world while a camera follows from behind and above, and players steer relative to what the camera shows. Building one well comes down to four pieces: camera-relative input, a character capsule that handles slopes and steps, an orbit camera with clamped pitch and wall collision, and an update order that keeps both smooth. In a browser game built on Three.js with Rapier physics, all four are a few hundred lines, and the values below are a solid place to start.
This is the build-level companion to our game camera guide, which covers follow, lookahead and shake in general. Here we go into the controller itself.
Camera-relative input
When the player pushes the stick up, the character should walk away from the camera, whatever direction the camera faces. Each frame:
- 01Take the camera's forward direction and set its vertical part to zero, then normalize it. That is "forward on the ground".
- 02Take the camera's right direction the same way.
- 03The desired move direction is `forward × stickY + right × stickX`. If its length is over 1 (a keyboard diagonal), normalize it, so diagonals are not 41 percent faster.
- 04Rotate the character to face the move direction, smoothly (see below), and move it.
One subtle trap: if the camera auto-rotates to follow the character while the player holds the stick sideways, the move direction rotates too, and the character walks in a slow circle. Either keep auto-rotation off while the player is steering sideways, or keep it so slow (and delayed) that it never fights the stick.
Character movement values
Measured in meters and seconds, with a character about 1.8 meters tall. Make every one a dial so you can tune by feel:
- Walk 2 to 3 m/s, run 5 to 7 m/s. Analog sticks scale between them; keyboards use walk with a run key, or run by default in action games.
- Acceleration: reach top speed in about 0.1 to 0.2 seconds on the ground. Deceleration: stop in 0.08 to 0.15 seconds. Slower than this feels like ice.
- Turning: rotate toward the move direction at about 10 to 15 radians per second (a smooth but fast turn). An instant snap looks robotic; slow turns make the character feel heavy and imprecise.
- Air control: 30 to 60 percent of ground acceleration. Some control in the air feels good; full control looks floaty.
- Jump height 1 to 1.5 m, with gravity a little stronger on the way down than up, plus about 0.1 seconds of coyote time and jump buffering. Our 3D platformer guide covers measuring jumps against level geometry.
The capsule and the ground
Use a capsule collider (radius about 0.3 to 0.4 m, total height about 1.7 to 1.8 m) controlled kinematically: your code decides where it wants to move, and a character controller resolves that against the world. Rapier includes a kinematic character controller for exactly this, with settings that matter:
- Step height: 0.3 to 0.4 m. Stairs and curbs are climbed automatically. Lower and the character snags on every edge; higher and it climbs things it should not.
- Max climbable slope: about 45 degrees. Steeper slopes block or slide the character.
- Snap to ground: 0.3 to 0.5 m. Keeps the character glued to the floor when walking down slopes or stairs, instead of skipping into the air at each step.
- A small skin offset (around 0.01 m) so the capsule does not rest exactly on surfaces, which causes jitter.
Keep the visual model separate from the capsule. The model follows the capsule's position, faces the move direction, and plays animations driven by speed (idle, walk and run blended by how fast the capsule moves) and by grounded state. Driving animation from actual speed instead of input means the character never runs in place against a wall.
The orbit camera
- Target: a point about 1.4 to 1.6 m above the character's feet (head height), optionally offset 0.4 to 0.6 m to one side for an over-the-shoulder view.
- Distance: 4 to 6 m for exploration, 2.5 to 3.5 m for aiming. Zoom with the wheel or a pinch within that range.
- Pitch clamp: about 30 degrees below the horizon to 60 to 70 degrees above. Without a clamp, the camera flips over the top.
- Sensitivity: mouse around 0.002 to 0.004 radians per pixel; touch drag a bit higher; always a setting, with invert Y.
- Follow smoothing: let the target catch up over about 0.05 to 0.15 seconds so small bumps do not shake the view, but keep it tight enough that the character never drifts off center during a sprint.
- Auto-recenter: only after 1.5 to 2 seconds without camera input, and slowly. Never while the player is moving the camera.
Camera collision
Each frame, cast a small sphere (radius about 0.2 to 0.3 m) from the target toward the desired camera position. If it hits something, place the camera just in front of the hit. Rapier's shape casts do this; a plain ray works but lets the camera clip into edges. Then:
- Pull in fast, ease out slow. Move in immediately when a wall blocks the view; ease back out over 0.2 to 0.4 seconds when it clears, or the camera pops in and out at every pillar.
- Ignore small things. Put the character, small props and foliage on a layer the camera cast ignores. A camera that jumps forward for every lamppost is exhausting.
- Fade the character when close. If the camera ends up within about 0.8 m of the character, fade the model out so the screen is not filled with the back of a head.
- Near plane around 0.1 m on the Three.js camera so walls do not cut through the view when the camera is pushed close.
Update order and jitter
The most common complaint about a homemade controller is jitter: the character or the world shakes slightly while moving. It almost always comes from update order or time steps:
- 01Read input.
- 02Step physics at a fixed rate (60 times a second is typical), as many steps as elapsed time needs.
- 03Interpolate the character's visible position between the last two physics states by the leftover fraction of a step. Without this, a 60 Hz physics world on a 120 Hz screen visibly stutters.
- 04Update the camera last, from the interpolated position.
- 05Render.
Also make all smoothing frame rate independent (use an exponential decay based on elapsed time, not a fixed fraction per frame), or the camera feels different on every device.
Controls on phones, keyboards and gamepads
- Keyboard and mouse: WASD to move, mouse to orbit (with pointer lock after a click, or holding the right button), Space to jump, Shift to run.
- Touch: a floating virtual stick on the left half of the screen, drag on the right half to orbit, a jump button under the right thumb. Our touch controls guide covers sizes and thumb zones.
- Gamepad: left stick moves, right stick orbits with a small dead zone (about 0.15), A or Cross jumps.
Startbase 3D games run on Three.js with Rapier physics ready to switch on, and are built to feel native on phones, with no page zoom or text selection over play (see the games docs). Dials you ask for appear in the Engine panel, so the values above can be tuned while you play.
A brief for a third-person controller
Build a third-person controller for my 3D adventure game using Rapier's kinematic character controller. Capsule radius 0.35 m, height 1.8 m, step height 0.35 m, max slope 45 degrees, snap to ground 0.4 m. Movement is camera-relative, normalized on diagonals; walk 2.5 m/s, run 6 m/s, reach top speed in 0.15 s, stop in 0.1 s, turn at 12 rad/s, 40 percent air control, jump 1.2 m with 0.1 s coyote time. Orbit camera targets head height, distance 5 m, pitch from minus 30 to plus 65 degrees, sphere-cast collision that pulls in instantly and eases out over 0.3 s, ignores small props and fades the character when closer than 0.8 m. Physics at a fixed 60 Hz with interpolation; camera updates last. Touch: left stick, right-side drag to orbit. Make every value an Engine panel dial.
Walk the character up stairs, down a slope, along a wall and into a corner before anything else; those four spots reveal most controller bugs. For scoping the rest of a 3D game, see how to make a 3D game without coding.
Frequently asked questions
How do I make a character move relative to the camera?
Flatten the camera's forward and right directions onto the ground plane, normalize them, and combine them with the stick input. Normalize the result so diagonal movement is not faster.
How far should a third-person camera be from the character?
About 4 to 6 meters for exploring and 2.5 to 3.5 meters when aiming, targeting a point near head height, with pitch clamped so it cannot flip over the top.
How do I stop the camera going through walls?
Cast a small sphere from the character toward the camera each frame and move the camera in front of anything it hits. Pull in instantly, ease back out over a few tenths of a second, and ignore small props.
Why does my third-person character jitter?
Usually physics runs at a fixed rate while the screen refreshes at another, without interpolation, or the camera updates before physics. Interpolate the visible position and update the camera last.

