Camera Shake

KT
2 min readDec 9, 2020

--

Today I implemented a camera shake effect whenever the player incurs damage. After perusing a number of tutorials on YouTube, I settled on one that created a basic animation by slightly moving the camera. Here were the main steps of what I did:

  • Create an idle animation (where the camera is stationary) which constantly runs until the camera shake animation method is called.
  • Create a basic animation with the main camera by using the main camera starting position, shifting it slightly to the left, back to center, slightly to the right, and then back to center.
  • Create transitions between these two animations (in the Animator) and add an OnTrigger event that can be called to switch from idle to camera shake states.
  • Create a new GameObject (CameraManager) and attach a new C# script to house the camera shake method.
  • Make a handle for CameraManager in Player script and call the _cameraShake( ) method in the damage method of Player.
Camera shake every time player incurs damage.

This worked out pretty well but I think the shake I made may be just a little too dramatic. The drawback of using the animation strategy is that in order to adjust the amount of shake, a whole new animation needs to be made. I did see (in some other tutorials) that the camera shake effect, its magnitude, as well as duration, were all able to be modified in code when the effect was created in code. So the current camera shake stays for now while I evaluate if it is, in deed, too much.

Next I’ve decided to tackle the Secondary Fire Powerup and make a new projectile. I’ll also be making a new Powerup for this weapon and I’ll have to figure out how to make it spawn rarely versus the current spawning which has been random so far.

--

--

No responses yet