Top down game, I’d like a camera shake to occur along an orientation, ex. according to the direction my character is currently facing, the direction from which something hits my character, etc.
My current guess is to use something as follows…
Add an Impulse Source to my character and a listener to my camera.
Create a new Fixed Signal, which operates in 3D
Via script: when I want to fire the source, I set the Fixed Signal “orientation” by way of script, then fire the impulse.
I know this is a bit lame to ask before trying, but things have gotten so feature-dense that I know find it’s very hard to know when to DIY versus use existing functionality. So is that above the right way to do it, or is there a smarter, built in way for Cinemachine to read the orientation of an Impulse Source?
… does not even remotely work, the camera shifts as if it uses maybe “Y” as “forward” is that possible? My character (as it should, uses Z as forward). What am I missing?
Notes:
Raw Signal: Fixed Noise, with X and Z values set to a descending linear curve 1 → 0
Amp and Gain: 1
Direction Mode: Fixed (my thinking is that I don’t want it to slightly “turn towards” the signal, I want to dictate the direction entirely through the GenerateImpulse call… is that wrong?)
Scale w Impact: True (just using the default)
Use 2D Distance: False (it’s a 3d game)
Totally stuck here, the docs are too abstract, and I can’t seem to find a descent example. Again, thanks for any help.
Click play.
Then click on the Epicenter gameobject. This has CinemachineImpulseSource script attached. Play around with the parameters until you find what you’d like to have. Use the Invoke button to test.
I think you’d like something like this:
ImpulseSource:
ImpulseListener:
NoiseDefinition:
In addition to the above, you’ll also need to calculate the direction of the force and set it to the
CinemachineImpulseSource default velocity:
For example:
The key thing is to have the principal movement along the Y axis of the impulse signal. Then, when you call one of the CinemachineImpulseSource.GenerateImpulse() methods, choose one that allows you to specify a velocity. Set the velocity parameter to be in the direction in which you want the shake to happen. The impulse signal will be rotated automatically such that its local Y axis will be in the direction of the generated impulse’s velocity.
Holy crap, thank you SO much for this response!! I’ve spent hours experimenting and searching online to get an answer to this. This worked perfectly for me. Same situation as OP, except sidescroller instead of top down