Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Camera Jumpy When Updating CinemachineSmoothPath

Discussion in 'Cinemachine' started by theDawckta, Mar 5, 2019.

  1. theDawckta

    theDawckta

    Joined:
    Jun 16, 2014
    Posts:
    52
    I am getting some jumpy movement from the CinemachineVirtualCamera when updating the m_Waypoints in my CinemachineSmoothPath. Code is simply what I have below, i run this every time I add a new section or delete a section. It does not jump around when adding onto the end of m_Waypoints only when trying to delete index 0 of m_Waypoints.
    Code (CSharp):
    1. void CameraWaypointsChanged(List<CinemachineSmoothPath.Waypoint> waypoints)
    2.     {
    3.         SmoothPath.m_Waypoints = waypoints.ToArray();
    4.         SmoothPath.InvalidateDistanceCache();
    5.     }
    Any way to remedy this?

     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,745
    I could have something to do with the path length changing.
    What is the nature of the changes you're making to the path?
    Does it jump when you replace the waypoints with an identical set?
    Can you show the inspector of the vcam that's jumping?
     
  3. theDawckta

    theDawckta

    Joined:
    Jun 16, 2014
    Posts:
    52
    It definitely is due to the path length changing. The camera can't handle automatically adjusting it's path position on the fly when you remove the 0 index waypoint from smooth path. When it jumps i am replacing m_Waypoint with an identical array with the 0 index removed.

    If I replace the waypoints with an identical set the camera is fine.

    I have 2 vcams in my scene, one for foreground and one for background, they are identical.

     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,745
    It's going to be very difficult to avoid the camera jumping when you change the path it's in the middle of riding. Is there any way you can accomplish what you're trying to do without changing the path shape?
    Why are you removing the waypoint?
     
  5. theDawckta

    theDawckta

    Joined:
    Jun 16, 2014
    Posts:
    52
    I whipped up a quick example scene illustrating the problem.

    Edit: Didn't see you reply until i uploaded that.

    I am removing the waypoints to clean up after myself. I am building an endless runner and by the time a level is finished there could be 1000's of waypoints so I was just making sure to not have a bunch of unused stuff behind my player.

    Is this expected behavior? I just wasn't sure, thought it might be a bug.
     

    Attached Files:

    Last edited: Mar 6, 2019
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,745
    ok, it's simpler than I thought. Just set the tracked dolly's z-damping to 0.

    upload_2019-3-7_15-24-46.png
     
  7. theDawckta

    theDawckta

    Joined:
    Jun 16, 2014
    Posts:
    52
    Thanks so much, I knew it had to be a knob I didn't tune! Great camera by the way!