shaking screen and blinking effects when player gets hit by enemies

hello everyone…

i was thinking of adding some damage effects to my player when hit by enemies…

explanation :

THE SHAKING SCREEN… when my character hits an enemy or gets shot… the camera would have the effect of being shaken violently by someone and the screen turns to a transparent color momentarily almost like Call Of Duty damage effects…

THE BLINKING EFFECTS… this case is a 2D game… when my player gets hit by an enemy… it will blinks quickly for 1 - 2 seconds and gains invulnerability only for that period…
and continues as usual… until it gets hit by another enemy again…

any ideas/ references/ snip codes/ etc… is appreciated…

thank you for your patience of reading this.

P/s : i don’t have any codes for this ideas, thus i need your help…

The way i would do it is like this,

make a new GUItexture and attach it to your camera so it is on your camera view.

Just make a texture like a white image, then select this as the texture and then make a simple script like this:

if oncollision(player_object : bullet){

  guitexture.active = true;
  yield waitforseconds(1);
  guitexture.active = false;

}

Don’t just copy this it will not work it’s just to give you an idea on how to do this.

I hope it clear some things

My simple solution for screen blinking

    IEnumerator flashScreen()
    {
        this.camera.backgroundColor = Color.white;
        this.camera.cullingMask = LayerMask.NameToLayer("Nothing");
        yield return new WaitForSeconds(0.05f);
        this.camera.cullingMask = LayerMask.NameToLayer("Everything");
    },

May I recommend my humble asset!
Damage Effect
It has a lot of different blinking effects. I’m sure you’ll find something suitable.

Demo