Dynamic waypoints on dolly track creates incorrect bezier curves

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:

// Apply the waypoints

dialogueDolly.m_Waypoints = new Waypoint[3];
dialogueDolly.m_Waypoints[0].position = startPosition;
dialogueDolly.m_Waypoints[1].position = midPosition + (Vector3.right * 2 * side);
dialogueDolly.m_Waypoints[2].position = finalPosition;

Any help would be greatly appreciated, thanks! :slight_smile:

5901782--629846--Dolly.gif

I think you need to call

dialogueDolly.InvalidateDistanceCache()

after setting the waypoints.

1 Like

Thank you for the response, that fixed the issue. :slight_smile:

1 Like