Shaking the screen (Camera + GUI )

I am currently adding a random vector the camera to simulate a shaking effect

However, it does not shake GUI elements on the screen (such as GUI.Label or GUI.Window). Is there a way to shake the viewport or the final rendered display?

2 Answers

2

Hi,

Think about how you paint the GUI on the screen... you write the coordenates where it should start... so, every time you repaint change the coordinates....

I suggest you to write a method for calculating coordinates, when the camera is still, when the camera shakes.

Hope this is a good solution.

I am looking forward to other solutions, and to see how do you solve this issue.

Good luck

If you're rendering GUI elements there should be a GUI layer component attached to the camera. The position of this can be accessed using:

camera.GUILayer.transform.position

you can move that around to simulate shaking as well as using the transform.translate function

http://unity3d.com/support/documentation/Components/class-GUILayer.html - GUILayer does not affect UnityGUI, which I am using (GUI.Label and GUI.Window)

woops looks like I missed that, I remember there being some overall thing that you could move to move the entire GUI though, as opposed to moving each element seperately