Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rotating along z axis
#1
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.





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.

 

 


Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
Rotating along z axis - by jose - 03-24-2014, 10:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mesh problem in generator after rotating control points ATHellboy 1 1,687 02-10-2020, 11:24 AM
Last Post: _Aka_
  Moving freely on the Y axis? clearleaf 6 5,196 01-30-2020, 11:21 AM
Last Post: ATHellboy
  y axis rotation flowerfire 1 3,504 12-22-2016, 08:14 PM
Last Post: Jake
  Weird anomaly when crossing an axis richadam 4 7,202 10-12-2015, 07:07 PM
Last Post: richadam

Forum Jump: