Search Unity

What can change cinemachine cams after LateUpdate()??

Discussion in 'Cinemachine' started by jin-archipin, Mar 2, 2020.

  1. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    upload_2020-3-2_10-12-26.png

    I have a virtual camera at (-908.7, 17.5, 18.7) and when I set this vcam to follow the player in front of the camera, it just jumps to somewhere like (-680.9, 17.5, 18.4) and slowly come back to original position.
    I'm struggling with this bug for like 3 days and had no luck. Is there anyone who knows well about this problem?
    Thanks in advance.
     
  2. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    Fun thing is it only occurs in first try. From second, it doesn't jump to weird position even though it runs exactly same code.
     
  3. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    upload_2020-3-2_11-2-45.png

    I made a coroutine for debug and used new WaitForEndOfFrame(); and this.
    so it changes between LateUpdate and EndOfFrame.
     
  4. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    upload_2020-3-2_11-59-13.png

    I think I tried to reset the position on every callback methods I can try and any of them didn't work...
     
  5. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    upload_2020-3-2_15-47-11.png
    I'm going to use workaround like this right now, but this is so disturbing...

    The problem occurs even when I put player to "follow" manually in inspector!!
     
  6. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    It is difficult to see what's going on, but if you could send me a project where I can reproduce the issue, then I may be able to help you.
     
  7. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    gaborkb likes this.
  8. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    The solution is to tick the Inherit Position (under Transitions), this will inherit the vcam's start position as the previousPosition. See the attached image for more details.

    Explanation:
    It is because the faraway vcam's initial internal previousPosition is (0,0,0), because it does not inherit the vcam's transform position. Then the system tries to put it to (900,0,0). And due to damping it does not happen instantly.


    After the first try, the previous position is correct, so the problem does not happen.

    @jin-archipin
     

    Attached Files:

    Last edited: Mar 5, 2020
    jin-archipin likes this.
  9. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    Thank you little bird!
    It works awesome
     
  10. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    @gaborkb One question here.
    Why is the unchecked inheritance default? What behavior was suppose to be normal?
     
  11. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    It's historical, and it can interfere with blends. But we'll consider changing it.


    :)
     
    Last edited: Mar 6, 2020
    jin-archipin likes this.