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!
S
andT
path commands. This image from the article linked shows it off well. \$\endgroup\$