Re: prevent entity from spinning
Posted: Mon Aug 30, 2010 7:30 pm
You can adapt the second alignToSurface approach to calculate the angles. Basically, you need to create a plane on which an angle measurement takes place, compute the coordinates (x, y) of the vector to measure on that plane, and take the Math.Atan2(y, x) to get the angle.
The plane can be created such that the orientation corresponding to zero is the perfect landing. This is done by creating the plane's two measurement axes from the appropriate systems. That is, you could use the normal (N) and a vector perpendicular to it and the orientation's right vector (N x orientation.Right), or whatever gets the measurement you want.
Of course, there's lots of other ways to do things like this, too.
The plane can be created such that the orientation corresponding to zero is the perfect landing. This is done by creating the plane's two measurement axes from the appropriate systems. That is, you could use the normal (N) and a vector perpendicular to it and the orientation's right vector (N x orientation.Right), or whatever gets the measurement you want.
Of course, there's lots of other ways to do things like this, too.