So here is what I've got and what I'm trying to do. I have a pretty basic 2D platform game I'm trying to set up. At one point when the player touches a trigger it causes some debris to fall down and take out a platform ahead of the character. I have that running fine, but what I would like to do is cause the camera to shake for a second or two to simulate a small earthquake before the debris comes down.
I looked around and didn't see any scripts to do it already out there, and no similar questions on here. So is it possible? And if so any help on getting it working would be greatly appreciated.
Of course it's possible, you just program it to do that. This has a script with a camera shake function in it; it might work for an earthquake, but if not, then make another function that works the way you want.
You can easily implement this by using Unity's Animation system.
1.) Add an Animation Component to your camera if it doesn't already
have one.
2.) Create a new animation for the camera.
3.) Add curves for Position.x, Position.y, Position.z
4.) Now create a few Keyframes along the first 50 or so frames.
5.) Go to each of your Keyframes and move each position curve slightly
up and down, and play until you get
it close to what you want. Save the
animation.
All you have to do to call the animation via script (assuming it's assigned as the default anim on the camera) is: