Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Persona · Feb 05, 2011 at 04:08 AM · camerascreenshake

Screen Shake Effect

I want to make the screen shake whenever a certain explosion is triggered and I need suggestions or an example. The shaking needs to be somewhat random up or sideways.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

7 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by buntu · Feb 05, 2011 at 07:13 AM

iTween has that kind of feature : http://itween.pixelplacement.com/index.php

And someone already asked for : http://answers.unity3d.com/questions/37345/itween-camera-shake

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Owen-Reynolds · Mar 27, 2011 at 05:27 AM

This is pretty cheesy code, just adds randoms to Y each frame for a short while, but gives a decent effect with the right numbers. It assumes Update is computing transform.position each frame (if not, it will "walk" the camera):

// === camera script // globals: float jiggleAmt=0.0f; // how much to shake

// Update // Code setting transform.position....

// At end of update: if(jiggleAmt>0) { float quakeAmt = Random.value*jiggleAmt*2 - jiggleAmt; Vector3 pp = transform.position; pp.y+= quakeAmt; // can also add to x and/or z transform.position = pp; }

// Others call this to cause an earthquake: public void jiggleCam(float amt, float duration) { // Amt is how many meters the camera shakes. 0.5 is noticable jiggleAmt = amt; StartCoroutine(jiggleCam2(duration)); }

IEnumerator jiggleCam2(float duration) { yield return new WaitForSeconds(duration); jiggleAmt=0; }

// === Some other script: // Calling from other code: Camera.main.GetComponent<cam1Script>().jiggleCam(0.5f,0.75f);

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by lzt120 · Jan 19, 2013 at 12:22 PM

Can this method apply to the case that using smoothfollow script ?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by littlehera · Oct 27, 2015 at 12:00 PM

Instead of shaking the screen, you can shake the camera. Here's a similar question that might help your problem. :) http://answers.unity3d.com/questions/755191/camera-shake-effect-constant.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by simulism · Jun 23, 2017 at 02:25 AM

I know this is old but, if you are using Itween, the code below will shake the screen when attached to the camera:

  iTween.ShakePosition(gameObject, iTween.Hash("y", 0.7f, "time", 1.5f, "delay", 2.0f));
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pamelacook · Sep 05, 2018 at 08:08 AM 0
Share

@simulism, your simple answer worked. I have tried for days trying to get a iTween camera shake while moving the camera to work. Your solution is the only one that stated that the ShakePosition logic had to be attached to the camera. I finally have my explosion working!!!

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Camera Shake 4 Answers

Is it possible to shake the screen rather than shake the camera? 3 Answers

Splitting the game view - part camera, part opaque navigational panel at runtime 1 Answer

How to "fade out" a scene 6 Answers

How do you clamp a camera by mobile width? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges