Search Unity

CinemachineSmoothPath and DollyCart: Orientation snaps when looping past last point

Discussion in 'Cinemachine' started by charlesroberts, Apr 6, 2022.

  1. charlesroberts

    charlesroberts

    Joined:
    Dec 14, 2021
    Posts:
    5
    I am using a CinemachineDollyCart on a looped CinemachineSmoothPath. When the path position passes the last point an loops around to the start there is a very visible snap. I've isolated the problem to the orientation. The position loops smoothly. To reproduce, make an oval or circular looped smooth path with four points. When the speed is set low enough, there is a very visible hitch in the orientation as the cart passes between point 3 and point 0. Can anyone offer a solution?
     
    Last edited: Apr 6, 2022
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Have you tried setting World Up Override on CinemachineBrain?
     
  3. charlesroberts

    charlesroberts

    Joined:
    Dec 14, 2021
    Posts:
    5
    @gaborkb, Thank you, but that did not help.
     
  4. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    What did you set the World Up Override? Try setting it to a Vector3.up.
     
  5. charlesroberts

    charlesroberts

    Joined:
    Dec 14, 2021
    Posts:
    5
    The World Up override is a Transform, not a Vector3, but I do not believe it is related. Perhaps I have not communicated the situation clearly enough. I have a circular CinemachineSmoothPath, with four Waypoints. I have a CinemachineDollyCart which has its Path field set to the CinemachineSmoothPath. A default CinemachineVirtualCamera is childed to the cart. The cart automatically moves along the track when the speed is non zero. The camera's fixed local rotation is 90 degrees in y axis and a few degrees down along x so it is looking toward and below the center of the track. As the cart is moving, the scene is smoothly rendered until the cart reaches the point on the track where it closes the loop (at waypoint 0). At this point the position of the cart updates smoothly, but the calculated orientation slightly snaps for one frame. This is easy to miss when using higher speeds. It is as if the tangent calculated for position 3.999 does not mirror the tangent calculated for position 0.001.
     
    gaborkb likes this.
  6. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Yes, I meant a transform that is not rotated.

    Could you send me a repro project? I'll take a look to understand the problem exactly.
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Yes, there does appear to be a rotational glitch in SmoothPath at the looping point. There are a couple of ways to work around this.
    1. Don't rely on the DollyCart's rotation. Create a LookAt target for the vcam and use the composer to look at it.
    2. If that's not possible, then you can replace the CinemachineSmoothPath component with a CinemachinePath component. You can then set the tangents manually. It does not suffer from the glitch at wraparound.
    upload_2022-4-7_12-50-36.png
     
  8. charlesroberts

    charlesroberts

    Joined:
    Dec 14, 2021
    Posts:
    5
    Thank you for the quick reply. I'll give the CinemachinePath a try.