Page 3 of 3

Re: prevent entity from spinning

Posted: Mon Aug 30, 2010 7:30 pm
by Norbo
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.

Re: prevent entity from spinning

Posted: Thu Sep 02, 2010 2:58 pm
by Marvin
yeah this kind of worked however my alignment to surface was computed later. The problem was there where some off-axis tricks so the orientation was not just 360 degrees for perfect landing it could also be 270 + 270 which made it odd so I added a separate counter for ther off-axis stuff, which works great now.

There are still some things that work a little odd right no. F/E when I'm jumping while the character is sliding backwards it jumps to the nose direction (so backwards as well) instead of the direction in which it's moving in. This is really weird since in the class the only thing jump does is just lineairspeed += new vector3(0, jumpspeed,0) this should always work in all orientations the same way right? since it's just world orientation and not internal orientation.
thanks

Re: prevent entity from spinning

Posted: Thu Sep 02, 2010 7:06 pm
by Norbo
Yes, the jump itself would be the same, but I'd recommend debugging through the code around the jump. Somewhere along the way the wrong matrix is used/computed.