Handheld Camera Shake (Constant Shake)?
Hello, Unity community! I was wondering how do I make this cinematic effect by script, but even after hours of research I couldn't find anything related to this. The only thing that I've seen is just an "one hit impact" kinda thing. By the research that I made, I was thinking that maybe you could achieve a very smooth camera shake with noise generation. Please note that I'm completely new to anything related to C#. Thank you very much!
Answer by lodendsg · Apr 25, 2020 at 10:46 AM
1st I strongly recomend Cinemachine https://unity.com/unity/features/editor/art-and-design/cinemachine
This makes doing things like this with cameras a lot easier. If you have this then what you could do is set up 2 vCams
1 that is your stable cam 1 that has camera wobble on it (feature of Cinemachine) set to a high frequency so its jaring
Then to start the shake you simply turn on the wobble camera ... to stop it turn it off.
this will work if your stable cam has a lower priority than your wobble cam ... so no need to turn stable cam off ... wobble cam will override it and the system will blend between them so no jerking at all.
Finally put both of these in a GameObject to act as a common root or have both of them track on the same target ... for info on that and what I mean their please study up on Cinemachine.
This tool will let you do most things with zero code, the rest you can do with very little code ... highly recomend it.
Thank you, but what would you do if you actually already have a working cutscene. Like replace the animations, or something?
Would depend on the nature of things.
Odds are you can easily get yoru current solution to work with vCams.
I'm guessing your moving a camera object around, settings values as you go to give various effects. Well you can do the same thing with vCams and in that case once you swap to using vCams you use the method I discribed above.
If you have already gone to far then you would need to build out your own noise and apply it with your own triggers. a samera shake is just a wobble applied to the camera transform ... a fast frequency is a violent shake like an explosion or sudden drop ... a slow wobble is head bob like effect. But ya I am a fan of using the professionaly developed tools Unity provides when they are their and do what I need so I would probably give it a go to convert to Cinemachine.
For note I am a software engineer with nearly 20 years of experance so quite comfortable coding my own solutions for just about anything yet I will still choose to a productized solution when it fits this saves me time, simplifies maintenance and lets me focus on other areas that may not be so well solved by some product.
So you can give vCams timeline animations? I watched the official tutorials but they didn't seem to show how to animate the camera by timeline. I am willing to change to Cinemachine even if I have to make the camera animation all over again.
Your answer
Follow this Question
Related Questions
How to negate shaking of moving object? 1 Answer
How I can make my camera keep a distance between two objects? 0 Answers
Simple Camera Switch Using C# 3 Answers
How to get photo image and work with it 0 Answers
C# Script for 3rd Person Camera? 1 Answer