# Create a continuous flight path on a Bezier Curve in Unity3d

I am working on a game in which a butterfly is flying along some path.

What I am trying to do currently is create a Bezier curve starting from the butterfly's position(previous curves end point) and the rest of the points random for it to fly on. Once it has finished on the curve it needs to continue its path along the next curve that is generated. The problem I have is that the next curve sometimes starts in a direction that makes the transition look rugged and unrealistic. This is the code I have so far.

void updateDirection()
{
if (!LeanTween.isTweening(this.gameObject))
{
Vector3 curveA = { transform.position, new Vector3(Random.Range(-5f, 0), 0, Random.Range(-3f, 0)), new Vector3(Random.Range(-5f, 0), 0, Random.Range(-3f, 0)), new Vector3(Random.Range(-5f, 0), 0, Random.Range(-3f, 0)) };
LeanTween.move(this.gameObject, curveA, 3f);
}
}


I am using the LeanTween API to create the movement method easier.

So basically I need to find a way to make a continuous bezier I guess and I am no mathematician so if it could be explained in easy to understand terms that would be amazing!

• Reflect the bezier control point to get maximum smoothness. SVG does this for the S and T path commands. This image from the article linked shows it off well. – MLM Jun 16 '15 at 4:08
• If you use quadratic Bezier curves, you could choose each subsequent point randomly within the circle described in this answer to get smooth transitions that respect some maximum acceleration amount. – DMGregory Nov 13 '15 at 13:40