I have a plane that can fly around over some terrain…
I can control the plane perfectly, and fly from visual and/or instruments…
HOWEVER…!
when I eventually change my planes orientation enough times, through course corrections etc, it freaks out and becomes over-sensitive to control inputs, and quicly flies off screen, twisting in chaos…
I use the following code to change pitch(stick forward / back):
My guess is that orientation.Right and orientation.Forward are becoming non-normalized and thru the feedback loop of changing orientation with itself causes it to numerically explode.
If you continuously add to a model’s rotation without resetting (as you are doing by multiplying a rotation matrix onto the existing orientation), the accumulation of floating point error will cause some odd behaviour, such as the model’s scale getting smaller. This is because the rotation in a matrix occupies the same cells that affect the model’s scale. Every floating point calculation has a small amount of error in it. By multiplying one matrix onto another, then multiplying another onto that, and another onto that, and another that, and so on, these floating point errors compound until they become significant enough to have a visible effect.
The way around this is to create the model’s transform matrix from a position, rotation and scale each frame. This means storing the position (Vector3), rotation (Vector3 or Quaternion) and scale (float or Vector3) separately, doing the updates on those (translating position, setting rotation), then create the matrix from those values. This way the only floating point error is the tiny amount from the matrix creation, and none from previous matrix operations.