# Implementing Screen Shake

I'm looking to implement screen shake in a 2D top down game. From an earlier Q on this exchange, I learned that noise values could be a good candidate, so I intent to try that.

But I wonder: is a screen shake more about rotating the 2D topdown camera, or about jittering the position of that camera?

Or does it really require both?

Additionally, I would like to know if a good screenshake would require motion blur? Something like rendering your world in 4 small micro-steps for each 60fps frame, maybe? Or can you shake the camera at 60fps with normal rendering and it still looks good?

The quality I am after is something like shown in this video. It's kinda hard to judge, but it seems that video does translational jitter only?

• I did run the linked video through an stabilizer that remove the translation, and I can confirm there is rotation. – Theraot May 25 '18 at 3:36

First off all, try it, see the results, and work from there. With that said, what you want is jittering, but let's be specific...

Keeping in mind that we are talking of a 2D game, the main effect is translation, you want to mainly add noise to the position of the camera.

Realistically, it is both translation and rotation, however, but the rotational effect is much harder to notice, and in particular for a 2D game, it is negligible.

Remember that we are simulating the camera standing on something which (or being hold by somebody who) shakes as a result of a shockwave or similar. If you imagine the camera being placed on tripod on the ground, and being hit by the shockwave, it will totter.

The camera-tripod system can rotate, with a rotation center near the ground, and a small rotation on that center, when converted to camera coordinates, will add a large translation (and about the same rotation).

Since in 2D, there is no Yaw and Pitch. Only the translation elements of these movement remains. About Roll, it will add to those translation (mainly to the horizontal one) and there will be a relatively less noticeble rotation left.

So, in order or magnitud:

• Horizontal movement
• Vertical movment
• Rotation

And who said the camera was on tripod anyway? Also, who said the world is 2D? You can always take your artistic licence on how the camera shakes. Just test it, and tweak it, and keep tweaking until you are happy with it.

On the kind of noise: We can also think of the system as a pendulum or a spring, and as such we want it to: 1) reduce magnitud over time, and 2) oscillate back and forth. Thus, using noise based on sine waves (such as Perlin noise) is a good idea.

On 3D: Translation is always more notorius than rotation. And in 3D translation in 3D can feel excessive. Thus, avoid using translation in camera shake for 3D games. Remember that we are using translation in 2D as stand-in for the missing rotations. Futhermore, moving the camera position can lead to clipping through walls.

On Accesibility: For some people, video games can make them feel nausea. One of the things that trigger this is camera shake. Thus, have the option to turn down and disable camera shake in your game.

On Motion Blur:

Additionally, I would like to know if a good screenshake would require motion blur? Something like rendering your world in 4 small micro-steps for each 60fps frame, maybe?

You can have motion blur. It is not required for a good camera shake. However, it can improve the general visual quality of the game.

In fact, you may also want a way to turn it off independently of the camera shake. In particular for players with older hardware who may have a performance hit because of motion blur.

Thus, I would consider motion blur orthogonal to the camera shake effect.