private void LateUpdate() { if (speed == 0) { return; } _time += Time.deltaTime * speed; if (_time > 1f) { _time = 1f; } Vector3 nextPosition = currentRail.GetPointAtTime(_time); Vector3 nextPoint = _time == 0 ? currentRail.BakedPoints[1] : currentRail.GetPointAtTime(_time + Time.deltaTime * speed); transform.position = Vector3.MoveTowards(transform.position, nextPosition, _time); //Quaternion lookRot = Quaternion.LookRotation(nextPoint, ); //transform.rotation = Quaternion.RotateTowards(transform.rotation, lookRot, Time.deltaTime * 1000f); //transform.LookAt(nextPoint); if (_time >= 1f) { if (_railIndex + 1 < rails.Length) { _railIndex++; _time = 0f; } currentRail = rails[_railIndex]; } }