Adding a Camera Shake when Player is Damaged

Jason Schneider
Sep 25, 2021

Googling “camera shake unity” gives us the following code to pilfer:

Creating a script called CameraBehaviour, and adding it to our Main camera and then adding the above method to this script.

Adding the following variable to our Player script:

Then add the following to the Start Method of our Player script:

Then add the following to the Damage() method in our Player script:

And as long as the starting position of our camera is (0, 0) the result will be:

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response