0

Share

GAME DEVELOPMENT

How To Create A Camera Shake Effect In Unity?

  • Home
  • Blogs
  • How To Create A Camera Shake Effect In Unity?

Camera shake is the blurring of a picture that occurs when the camera is moving at the time of exposure. The drag-and-drop method for customized shaking effects.

Agnesh Pipaliya

June 29, 2022

Are you trying to give some real effect to your game? 

Camera shake is one of them. It gives the feeling of chaos, disorientation, or realism. And it is usually used in action games while moving at a fast speed or when a large impact or explosion occurs.

You can use this camera shake effect for your game project to create an effective game with a compelling story. Take a look. 

 

 

Step - 1: Create Project

First of all create a brand new unity 3D project and set the scene as shown below. create some other game objects like sphere, cube, etc.

 

 

Step - 2: Import DoTween Plugin

Now import DoTween plugin in to your project from unity asset store which are totally free.

 

 

Step - 3: Create Camera Shaking Script

Now create new C# script and give name what you like, in my case I am just save this with names like “MyCameraShaking.cs”.

Next just copy and paste the below mentioned code into your script, I set this code in to my “MyCameraShaking.cs” and then save the script.

Now create new game object name with “Shake Manager” in hierarchy and assign this script to this game object and give camera reference to the script from hierarchy.

 

 

Step - 4: Test Demo

Now jump run the scene and you will see your all environment in the scene is shaking with some vibration frequency that you set in the code.

Explanation Of DoTween Shake Method

DOShakePosition(Float Duration, Float/Vector3 Strength, Int Vibrato, Float Randomness, Bool Snapping, Bool FadeOut)

Shakes a Transform's localPosition with the given values.

duration - The duration of the tween.

strength - The shake strength. Using a Vector3 instead of a float lets you choose the strength for each axis.

vibrato - Indicates how much will the shake vibrate.

randomness - Indicates how much the shake will be random (0 to 180 - values higher than 90 kind of suck, so beware). Setting it to 0 will shake along a single direction.

snapping - If TRUE the tween will smoothly snap all values to integers.

fadeOut (default: true) - If TRUE the shake will automatically fadeOut smoothly within the tween's duration, otherwise it will not.

Conclusion

In this blog, you have learned about the camera shake effects. You can use it in different ways for your game projects, whether it is to portray a scene where a bomb goes off, a barrel explodes, or you get hit by a gun; it is effective everywhere. 

Develop your games with a camera shake effect to give a real view to your users. 

 

img

Agnesh Pipaliya

COO of Vasundhara Infotech, a leading Software development company in the USA. His technological interests has helped the company in making useful decisions.

message

Have a project in mind? Drop a message to Bansi Pipaliya & start the discussion!

Get a Newsletter

Sign Up to our newsletter to get latest updates staight in your inbox.

Vasundhara respects your privancy. No Spam!

Get a Newsletter

Sign Up to our newsletter to get latest updates staight in your inbox.

Vasundhara respects your privancy. No Spam!

message

Have a project in mind? Drop a message to Bansi Pipaliya & start the discussion!

Latest 13 Web Development Trends To Expect In 2022
April 11, 2022 Category : company news

Revealing Vasundhara’s New Identity

Read More
Latest 13 Web Development Trends To Expect In 2022
May 17, 2022 Category : web development

Latest 13 Web Development Trends To Expect In 2022

Read More
Leave a Comment