Unity3d Shock Screen effect

Source: Internet
Author: User

Unity3d the screen effect, bind this script to the main camera and call Shakecamera (); The code is as follows
using unityengine;using system.collections;public class sc_shakecamera :  monobehaviour { private float shaketime = 0.0f;private float fps=  20.0f;private float frameTime =0.0f;private float shakeDelta =0.005f; public camera cam ;p Ublic static bool isshakecamera =false;// use  this for initializationvoid Start  () {shaketime = 1.0f;fps= 20.0f; frametime =0.03f;shakedelta =0.005f; } // update is called once  per framevoid update  () {if  (Isshakecamera) {if (shaketime > 0) {shakeTime - = time.deltatime;if (shaketime <= 0) {cam.rect = new rect (0.0f,0.0f,1.0f,1.0f); isshakecamera =false;shaketime = 1.0f;fps= 20.0f;frametime =0.03f;shakedelta = 0.005f;} Else{frametime += timE.deltatime; if (frametime > 1.0 / fps) {frametime = 0;cam.rect =  new rect (shakedelta *  ( -1.0f + 2.0f * random.value), ShakeDelta  *  ( -1.0f + 2.0f * random.value),  1.0f, 1.0f);  }}}} }  public static void shakecamera () {isshakecamera =true;}} You can also refer to http://blog.csdn.net/dujimache123/article/details/8149850


Unity3d Shock Screen effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.