Hi, everybody. For a start here such screenshot.
At the left - result of LookAt and LookRotation.
On the right - result necessary to me.
Initially the cube costs parallel to the camera.
I should make so that the object not simply looked at the second vector, but also calculated turn. (if to watch a screen) on axis X.
As a result the algorithm shall look approximately so:
However seemingly suitable function Quaternion.FromToRotation() doesn’t give out result…
for (int p = 0, f = 0; f < frequency; f++) {
for (int i = 0; i < items.Length; i++, p++) {
Transform item = Instantiate(items[i]) as Transform;
Vector3 position = spline.GetPoint(p * stepSize);
item.transform.localPosition = position;
if (lookForward) {
Quaternion rot = Quaternion.FromToRotation (Vector3.forward, (spline.GetDirection((p+1) * stepSize)));
item.transform.rotation = rot;
}
item.transform.parent = transform;
}
}
P.S.: To calculate local turn from transforms not option. Where I need this function transforms have no turn.