How move object on Bezier path?
I managed to implement the Bezier algorithm, now I wanted to use it in the update to do iteration of movement for a path. In this case, should I change the operation? I do not like sliding nodes in Update()
private Vector3 Bezier(float t, Vector3 p0, Vector3 p1, Vector3 p2) { float u = 1 - t; float tt = t t; float uu = u u; Vector3 p = uu p0; p += 2 u t p1; p += tt * p2; return p;
}
private void Update()
{
for (int point = 0; point < path.Length - 2; point +=2)
{
curr += Time.deltaTime;
perc = curr / 10f;
tr.transform.position = Bezier(perc, path[point].position, path[point + 1].position, path[point + 2].position);
}
}
Comment