- Home /
Constant camera shake.
I used to have this weird system in which I used this script on a sphere in the distance being followed by the camera, but it would of course bump into the geometry in the scene. Is there a way to change the xyz coordinates of the camera randomly in a certain range indefinitely?
This blog might help: http://unitytipsandtricks.blogspot.com/2013/05/camera-shake.html
Answer by efge · Apr 21, 2011 at 08:56 AM
You could use this in an Update function:
transform.position = Vector3(Random.Range(minX, maxX), Random.Range(minY, maxY), Random.Range(minZ, maxZ));
You need to keep in $$anonymous$$d that, that particular piece of code would always randomize the position, meaning that it would just randomly fly off very shakily.
A good idea using this method would be to get an empty gameObject moving the camera, and have the camera (not as a child) moving to it's positon, then shaking, then moving to the empty object's position, and so on. Before this happens you would need to perhaps find it's position, shake it, then
Your answer
![](https://koobas.hobune.stream/wayback/20220613124156im_/https://answers.unity.com/themes/thub/images/avi.jpg)