Search Unity

Screen Shake

Discussion in 'Cinemachine' started by Vallar, Nov 19, 2019.

  1. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177
    Hi,

    I am trying to create a screen shake effect when I destroy an enemy or when an enemy is hit. Previously in Cinemachine this was dead simple, it was just getting a component and applying the values. Now it seems I can't access the noise module in the virtual camera for some reason.

    Then I came across this Impulse module thing and it just looks rather overwhelming and complicated for just a simple screen shake. Not even sure how to use that properly, given it is new... not a whole lot about it out there.

    Any ideas of what one can do?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    You can still access the noise module, nothing has changed in that regard. What version of CM are you comparing to?

    Don't be scared off by impulse. Have a look at the Impulse example in the example scenes. When the enemy is hit, emit a signal. Add a signal listener to your vcam, and it will shake. It really isn't all that complicated.
     
  3. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177

    Hmm... that example was really helpful. Thanks a lot. I got it up and running in a matter of minutes.

    Nonetheless, could you tell me how to access the noise module now, just in case? I am using Cinemachine 2.3.4. Basically just want to set it from "None" to "Berlin noise" and modify the settings of said noise.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    var noise = vcam.AddCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
    noise.m_NoiseProfile = bla
    noise.m_AmplitudeGain = bla
    etc

    See the Scripting example scene in the CinemachineExamples for more.
     
  5. Vallar

    Vallar

    Joined:
    Oct 18, 2012
    Posts:
    177
    That is precisely what I needed. Thanks a lot.
     
    Gregoryl likes this.