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.
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.
Now import DoTween plugin in to your project from unity asset store which are totally free.
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.
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.
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.
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.
COO of Vasundhara Infotech, a leading Software development company in the USA. His technological interests has helped the company in making useful decisions.
Sign Up to our newsletter to get latest updates staight in your inbox.
Vasundhara respects your privancy. No Spam!
Sign Up to our newsletter to get latest updates staight in your inbox.
Vasundhara respects your privancy. No Spam!