Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How do I do a simple shake over a specific duration?

Discussion in 'Cinemachine' started by mrCharli3, Oct 8, 2023.

  1. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    956
    Spent the last hour trying to figure out how to use the impulse listener to generate a long steady shake like the 6D shake where I control the duration, but I cannot find any references on how to achieve this through code.

    I just want to tell it to "Activate 6D noise for X seconds". I know how to activate it via the inspector, but not via code.
     
  2. antoinecharton

    antoinecharton

    Unity Technologies

    Joined:
    Jul 22, 2020
    Posts:
    156
    Heyyoo :)
    Which version of cinemachine are you using?
     
  3. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    956
    2.9.7 :)
     
  4. antoinecharton

    antoinecharton

    Unity Technologies

    Joined:
    Jul 22, 2020
    Posts:
    156
    Check this :)
     
  5. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    956
    But your latest communications have said we should use the impulse listener, now you link a video that doesnt use it?
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
  7. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    956
    Okay, but youve made it sound like anything not using impulse is legacy in old communications. So is it fine to use noise as in the video?

    This is such a simple thing to do with a custom camera, so just considering skipping cinemachine tbh.

    Is there no way to control impulse duration?
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    The script in the linked thread shows how to turn a continuous shake on and off by toggling the Active bool member variable. You can augment it by adding methods that take a duration param, or by setting a specific duration. You can have multiple such emitters each with their own duration. Results will be cumulative. How you want to implement it is up to you.

    As for using the noise as in the video, that's fine but it will mean that you can't have other noise (such as hand-held camera shake) on that vcam. The advantage of Impulse is that it won't interfere with other camera noise.
     
    antoinecharton likes this.