Search Unity

Bug Impulses occurs multiple times

Discussion in 'Cinemachine' started by DoctorShinobi, Dec 4, 2020.

  1. DoctorShinobi

    DoctorShinobi

    Joined:
    Oct 5, 2012
    Posts:
    219
    Hey!
    There seems to be a bug that causes impulse sources to emit multiple times. Shockingly the extra screen shakes can occur even after you exit play mode and enter a new play mode session again. This is a really annoying issue that I can't find a workaround for.
    I filled a bug report a month ago only for it to be answered with "this has been fixed in 2020.2b6". The bug was reported with b9 and occurs all the way until the current b14 version.

    I'd be happy if someone on the cinnemachine team could take a look at that. The case number is 1290171. This occurs in both cinemachine 2.6 & 2.7.1.

    Thanks!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    I've opened your repro scene with 2020.2.0b12 and CM 2.6.3.
    I press Play and then spacebar.
    I see the impulse.
    I wait a long time.
    There is no second impulse.

    What am I missing?

    EDIT: not sure why you got a "fixed for 2b6" response - I was never able to repro this issue. Perhaps someone mistyped a bug ID and got this one by mistake
     
    Last edited: Dec 4, 2020
  3. DoctorShinobi

    DoctorShinobi

    Joined:
    Oct 5, 2012
    Posts:
    219
    You're not missing anything, that's all you're supposed to do to reproduce it. It doesn't happen every time, but it does happen about 80% of the time so it shouldn't be hard to reproduce.
    Can you try reproducing it like this?:
    1) Press play then space bar.
    2) Immediately after the impulse is over exit play mode and enter again
    3) Do nothing. The impulse should play again without your input as long as you executed step 2 quickly enough.

    If this still doesn't work then I don't know what else to suggest to reproduce it. But I'm certain this definitely occurs as explained on my computer.
     
    Last edited: Dec 4, 2020
    marc_tanenbaum likes this.
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Bingo! Now I can repro it. The key is exiting playmode then re-entering.

    Indeed this is a bug - Impulse needs to be cleared on playmode start.
    We will fix it.

    In the meantime, here is a workaround: add this code somewhere in your project (I put it in your Shaker.cs and it did the job).

    Code (CSharp):
    1.     [RuntimeInitializeOnLoadMethod]
    2.     static void InitializeModule()
    3.     {
    4.         CinemachineImpulseManager.Instance.Clear();
    5.     }
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    The bug will be fixed in CM 2.7.2. Thank you for bringing this up, and for following up on it. Much appreciated.
     
    DoctorShinobi likes this.