Unity2D Devlog 09 — Put a Little Shake On It

Claudio Grassi
4 min readMay 13, 2021

Creating an immersive experience for the player is the dream. I can’t code a way for the player to feel the hits physically. That is a good thing, for obvious reasons. However, I still want them to experience the impact of the damage they sustain. I can use a simple trick to achieve this.

Objective:

Implement Camera Shake when the payer is damaged.

How I went about it:

Creating Camera Shake can be achieved in a few different ways. If you’re using a perspective-style camera, you could change its viewing angle. You could also alter the camera’s position in any direction and back again. I went with a more simplistic approach.
I decided to use animation to control the change in my camera’s Orthographic Size. This approach will allow me to create an animation clip that I can play every time my player takes damage. The process to achieve this result was quite simple.

I began by attaching an Animator Component to my Camera. I then created a new Animation Clip and named it CameraShake. I keyframed a subtle change in the Camera’s Orthographic Size value. Just enough to give the impression of a quick jolt. You can find more information about this property on the online Unity Documentation page.

--

--

Claudio Grassi

Experienced digital artist, Unity game developer & coder with a knack for problem solving and a passion for video games.