Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

You can see the effect in many games. The camera sways or wiggles a bit while walking to make the movement feel more realistic.

I have implemented a camera in my game. (Who'd have thunk it?) So is there a common approach to build this swaying effect in?

share|improve this question
It's usually just a sinewave, take a look at this: – bryan226 Dec 24 '12 at 11:19
An alternative would be parenting a camera to a rigged characters head resp. eye bone. The movement of the camera will then follow the movement of the character. Ofc, just using sine waves is easier to implement and compute. – sarahm Jan 10 '13 at 23:58
@sarahm. Since there are no character animations implemented in my game yet, I can't do that now. But I would like to implement that some day. – danijar Jan 11 '13 at 10:12
See here… – Byte56 Jan 14 '13 at 19:52
possible duplicate of How can I implement view wobble when my player is running? – Byte56 Jan 14 '13 at 19:52
up vote 8 down vote accepted

Applying a transformation to the world from the point of view of the camera is the most straight forward way.

When the character advances the camera can be modeled as a cartwheel without the wooden circle, keeping just the wooden sticks. This curve is called cycloid.

enter image description here

Also with each foot step the camera needs to move slightly to one side or the other as if the wooden sticks where separated by the horizontal distance between the two legs, balancing the center of mass to keep it vertically aligned with the foot touching the ground.

enter image description here

The two movement seen from the point of view of the camera would look like half a circle (or an ellipse).

Approximating the cycloid to a sinusoidal, the translation would be given by:

translation( A * cos(d + pi/2), B * sin(pi/2 - 2*d), 0 )

Where d is the distance since the character started to move. The movement speed can be modified by multiplying d by a factor, or the values of X or Y by an arbitrary amplitude.

enter image description here

share|improve this answer
Fantastic visualizations! +1 – Gerstmann Jan 17 '13 at 11:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.