03-24-2014, 10:31 PM

Hi there, I am having a problem. This is the situation: I have a 2d rectangle and I need it to follow a spline (drawn over the edege of a curving, continous terrain). I use the SplineWalkerDistance script as a base, but I need the rectangle to rotate only around the z axis. So if for example the terrain curves up 40 degrees, the rectangle rotates around the z axis 40 degrees. I am trying to use this code (the rest of the script is the same as the original), but it is not working.

I'm probably not understanding how transform works in unity, or how GetOrientationFast works, but I've read the documentation and I just can't figure out how to do it.

Thank you

Ps: I have attached a screen capture to ilustrate the problem.

Code:

`if (SetOrientation) {`

Quaternion tan = new Quaternion();

tan = Spline.GetOrientationFast(tf);

transform.rotation = Quaternion.Euler(0f,0f,tan.z);

Dir = dir;

}

I'm probably not understanding how transform works in unity, or how GetOrientationFast works, but I've read the documentation and I just can't figure out how to do it.

Thank you

Ps: I have attached a screen capture to ilustrate the problem.