I have a 3D-object that is navigating the CatmullRom spline. The code I'm using is taken from Xoppa's answer here: Xoppa's answer
There are 2 ways of aligning object along thre spline. I tried both of them. And have weird results with both. Option 1 (it mostly OK but have a weird rotations occuring...see image below):
Option 2 (removes issue from Option 1 but everything else is not okay..see image below ):
My spline:
pointsArray = new Vector3[21];
pointsArray[0] = new Vector3(-5, -2, 2);
pointsArray[1] = new Vector3(-4F, -1F, 2);
pointsArray[2] = new Vector3(-3F, -0.5F, 2);
pointsArray[3] = new Vector3(-2.0F, 0.3F, 2);
pointsArray[4] = new Vector3(-1.0F, 0F, 2);
pointsArray[5] = new Vector3(0F, -0.5F, 2);
pointsArray[6] = new Vector3(1F, 0.5F, 2);
pointsArray[7] = new Vector3(3F, 1F, 2);
//loop
pointsArray[8] = new Vector3(3.5F, 1F, 2.25F);
pointsArray[9] = new Vector3(3.6F, 1F, 2.5F);
pointsArray[10] = new Vector3(3.5F, 1F, 2.75F);
pointsArray[11] = new Vector3(3F, 1F, 3F);
pointsArray[12] = new Vector3(2.5F, 1F, 2.75F);
pointsArray[13] = new Vector3(2F, 1F, 2.5F);
pointsArray[14] = new Vector3(1.5F, 1F, 2.25F);
pointsArray[15] = new Vector3(1F, 1F, 2.2F);
pointsArray[16] = new Vector3(0F, 1.2F, 2F);
pointsArray[17] = new Vector3(-1F, 1F, 2F);
pointsArray[18] = new Vector3(-2F, 1.2F, 2F);
pointsArray[19] = new Vector3(-3F, 1F, 2F);
pointsArray[20] = new Vector3(-4F, 0.8F, 2F);
catmull = new CatmullRomSpline<Vector3>(pointsArray, false);
So I need either to eliminate the rotations from option1. Or (think much simpler) to fix the option2 to rotate my object correctly. I think there's a simple thing that I'm missing that someone who's good with vectors can spot easily.