Phase 1: Camera Shake
Objective: Add a camera shake effect when the player is hit.
For the camera shake we will create a CameraShake script and attach it to the Main Camera. We will use a simple coroutine to move the camera in small adjustments left and right, up and down very quickly and then return the the starting point.
Next on the player script, create a private CameraShake and assign it in the Start method using the Camera.main GetComponent and remember to null check. Inside the players TakeDamage method call the CamShake coroutine but unlike a normal method call, we are calling a coroutine so remember to start the coroutine when making the calling.
To add a little spice to the shake, we will use the Post Processing Volume to add a little color when hit. In the player script, create a serialized private PostProcessVolume and remember to import the necessary namespace(using UnityEngine.Rendering.PostProcessing). We will adjust theColor grading and Bloom so, create a private entry for both.
Now set the profile connections in the Start method.
We will then use another coroutine triggered at the same time as the camera shake and adjust the temperature and tint of the color grading along with the intensity of the bloom before going back to the settings we chose when setting up the Post Processing.
In the next post, we will clean up the UI and add some more elements for powerup display.