Search Unity

Dynamic waypoints on dolly track creates incorrect bezier curves

Discussion in 'Cinemachine' started by Osteel, May 26, 2020.

  1. Osteel

    Osteel

    Joined:
    Jan 17, 2014
    Posts:
    59
    Hi!

    I've been working on a simple NPC dialogue camera where a cinemachine camera will essentially move closer to the actor when interacting with them. To make it a little more polished, I've been using a dolly track to curve the camera around using a 3 waypoint setup.

    The waypoints are generated at runtime and are correct. However, after the first usage (first interaction), the curves are not generating properly. What's interesting is that if I adjust any of the waypoints manually in any way, the curve immediately corrects itself.

    I've uploaded a gif to show what's happening.

    Here is a code snippet of the assigning of the waypoints:

    Code (CSharp):
    1.  
    2. // Apply the waypoints
    3.  
    4. dialogueDolly.m_Waypoints = new Waypoint[3];
    5. dialogueDolly.m_Waypoints[0].position = startPosition;
    6. dialogueDolly.m_Waypoints[1].position = midPosition + (Vector3.right * 2 * side);
    7. dialogueDolly.m_Waypoints[2].position = finalPosition;
    8.  

    Any help would be greatly appreciated, thanks! :)
     

    Attached Files:

  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    I think you need to call
    Code (CSharp):
    1. dialogueDolly.InvalidateDistanceCache()
    after setting the waypoints.
     
    Gregoryl likes this.
  3. Osteel

    Osteel

    Joined:
    Jan 17, 2014
    Posts:
    59
    Thank you for the response, that fixed the issue. :)
     
    gaborkb likes this.