Global shake/impulse independent of active Vcam?

Is it possible to have a sort of global impulse listener, which is not bound to its VCam?

The problem is that most of my CamShakes never occur because of the way the system works.

Setup:
I have 2D rooms which activate their VCams when the player enters (OnTriggerEnter), and deactivates that VCam OnTriggerExit, which then blends between the different Vcams.

Example:

  • the player dies, deactivates, is moved to the last checkpoint, and is reactivated after a short pause
  • the CamShake that was to take place to emphasize the player’s death never occurs, since the Vcam with the impulse listener deactivates OnTriggerExit (the player has just been deactivated). But I need this system to navigate the various rooms.

No shakes either if they happen to be triggered from the Vcam that is being transitioned from.
I have many such situations.

So is there some sort of global impulse setting to create a shake which is independent of the currently active Vcam?
Thanks.

Impulse events are completely independent of the vcams. Anything with a listener will react to an impulse event. If you have impulse listeners on all your vcams, listening on the same channel, then they will all respond to any impulse within range. If you have listeners on all the vcams and they are not responding, then maybe the range is to small on the impulse source events? The signal dissipates with distance, but you can control the distance and the dissipation rate.

The idea is that impulse signals are emitted from somewhere in your game (when and where something important happens). It’s analogous to a sound being emitted. Vcams are just listeners. They react. The impulse happens regardless of how many listeners there are.

Thanks, but setting the impact radius very high has zero effect on my problem.

As explained, my VCams only activate when the player enters their trigger zone, and deactivate when leaving it.
So unless during a camera blend, there is never more than 1 active Vcam gameobject in the scene.

In certain cases, there are 0 active VCams in the scene, like in the case mentioned above, when the player dies.

This is the process

  • player is hit
  • Cinemachine Impulse Source triggered
  • Player deactivates (= exits the trigger zone)
  • which leads the only active Vcam gameobject in the scene to also deactivate
  • so while the Main Camera still displays the correct view, there is no more screen shake
  • player respawns
  • VCam linked to that trigger zone activates

I have other similar scenarios, which is why I was looking for a CM shake extension independent of which or if any VCams are even active in the scene. Sort of just hooked to the Main Camera and not the VCams.

ok, I understand now that there are no vcams active during the time in question, so your original question makes more sense to me.

Yes, you can easily write a custom impulse listener and attach it to anything, including the main camera. If you do that then you won’t need listeners on the vcams - the single one on the main camera will do the job.

Take a look at CinemachineImpulseListener.cs. The code there shows how to query the impulse system for the signal at a point in space. Then, instead of applying that signal to the vcam state, your custom script can apply it directly to the transform. Do this in LateUpdate. If you attach this to the main camera, there is one gotcha: make sure to set its script execution order to be after CinemachineBrain, or its effect will be erased by the brain.

If you do this, feel free to post your script here. I’m sure it will be of interest to others.

1 Like

Will try this out and post the script if successful. Many thanks.

ps.: the solution I have been using in the meantime to always have an active Vcam, was to make a VCam with an impusle listener a main camera component, but with a priority of -100 or something like that.
Then, during the death events, this is the Vcam that pics up the screenshakes. But it very much feels like a hack.

I’ll have to go with the hack. Did not manage to make anything functional with the contents of CinemachineImpulseListener.cs.

CinemachineIndependentImpulseListener is the way. Add that sucker to your CinemaMachineBrain. Not sure when this was added. By default it is later in the Script Execution Order as well.

Hope this helps someone. I didn’t want to do this:

1 Like