Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

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:
    50
    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:
    145
    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:
    50
    Thank you for the response, that fixed the issue. :)
     
    gaborkb likes this.
unityunity