Here is the problem: ship on the sea (XY plane).Ship turns left right ok. When turning I want the ship to heel (rotate a little along the longitudinal axis).
Left right turning works ok with this code:
var rotationVector = GameObject.Find ("SHIP").transform.rotation.eulerAngles;
rotationVector.x = 0f;
rotationVector.y = 0f;
rotationVector.z = rotationVector.z + 0.5f; //well , a function anyway
GameObject.Find ("SHIP").transform.rotation = Quaternion.Euler(rotationVector);
If I try to add the second rotation on the Y axis (the heeling), the resultant rotation gets weird.
var rotationVector = GameObject.Find ("SHIP").transform.rotation.eulerAngles;
rotationVector.x = 0f;
rotationVector.y = rotationVector.y+ 0.5f;
rotationVector.z = rotationVector.z + 0.5f;
GameObject.Find ("SHIP").transform.rotation = Quaternion.Euler(rotationVector);
As far as I get it, the rotation is local, and heeling takes steering off the horizontal and the ship goes either airplane or submarine. I could make an Z adjustment each frame to compensate but I don’t get the heeling!
Tried 2 rotations stages, tried fist one then the other, variants from forums but I can’t get it working…
How to get the banking local and the turning global on the same object?
This is getting me bugnuts
Heelp!?!