Hi,
I have searched forums high and low and I managed to do this in blitz3D via the AlignToVector command but I can’t actually repeat the behaviour in Unity.
Basically, I have mesh hills and a character. It’s semi 2D game from above looking down. The camera does not rotate.
The character should be able to rotate around the Y axis (ie look left and right) however the body should tilt forwards and backwards based on ground angle without messing with what direction he is looking with. Bit like watching a tank go over hills or something.
I got the normal from the collision contact then:
var surfaceRot : Quaternion = Quaternion.FromToRotation (Vector3.up, averageN);
var newRot : Quaternion = surfaceRot * Quaternion.AngleAxis(transform.rotation.eulerAngles.y, Vector3.up);
meshObj.transform.rotation = Quaternion.Slerp(meshObj.transform.rotation, newRot, 0.2);
However it messes everything up when I try to rotate it on the spot. Any ideas of a better approach?