Unity3D: Camera Shake Effect with C# Example

One of my unfinished Unity3D game projects required camera shaking function, so I wrote one from scratch.

I just needed a script that shakes camera for a certain time and magnitude, and can be called from other script. Also, sometimes it would be useful to trigger this from UI button using OnClick().

Added 9.10.2018: This script is now available also at GitHub:
https://github.com/jliias/CommonUnityScripts/blob/master/CameraScripts/ShakeCamera.cs

Please find script below:

Script is added as a script component to the Camera type object and then it should be ready for use. You just have to figure out how and when to trigger it in your own game.

I hope that someone will find this script snippet useful!

-Jussi

Comments

  1. I am impressed with the post which you have shared. The blog you have shared is incredibly helpful. The tips you have shared related to web development is really informative. Thanks for sharing this blog!
    Unity 3D Game Development Services

    ReplyDelete
  2. I am really happy to say it’s an amazing post to read. I learn new information from your article, you are doing a great job. Keep it u

    Poker Game Development Company

    ReplyDelete

Post a Comment

Popular posts from this blog

Unity3D mirror using camera and RenderTexture

Construct 2: if-then-elseif-else statement

Unity3D: Convert Seconds to hh:mm:ss Format