I’m having issues thinking of a good way to align my bike to the surface its riding on by modify the local z axis, without messing up the rigidbody simulation. I am able to get my bike to balance by modifying the transforms local euler angles as such:
var euler = transform.localEulerAngles;
// Only works for staying upright relative to ground plane
transform.localEulerAngles = new Vector3(euler.x, euler.y, -steerLean);
The issue here is that when I go up a vert ramp the bike aligns, obviously, straight upwards. I cannot think of / recall a good way to keep the object upright but keep the rigidbody simulation intact otherwise.
I have tried to use Quaternion.FromtoRotation but this does not seem to want to play nicely. The object flops from left to right and eventually just falls over.
My bike uses WheelColliders and is working fine other than this issue.
Picture above for reference. The bike is moving and should be leaning to the right.

So, I understand the part about getting the normal of the two tires. The part I am struggling with is how to convert that vector to the local euler angle I need for the z axis of my bike.
– SudoSandwichI tried the mass idea and it is something I can work with. I applied force relative to the inverse of the average ground normal of the two tires and lowered the center of mass. Now to turn I am adding relative torque instead of directly modifying the euler angles. Thanks for the help
– SudoSandwichOk, cool, good, because I'm still struggling to work out the details of how to do the first one. Involves fun vector math.
– SpinnernicholasHow is it going?
– Spinnernicholas