Greetings Unity Community.
I am currently working on a small project to create a MotoCross style dirt bike simulator/game. So far I have gotten an object hierarchy like such:
Bike Body Wheels Front Rear Wheel Collider FrontCol RearCol
I am actually rather happy that I have also been able to use a simple script to produce forward velocity using RearCol.motorTorque * Input.GetAxis("Vertical"). Add a bit of drag and I have a basic motorcycle that can accelerate forward and slow to an eventual stop when I release the throttle.
Now comes the part I haven't found an answer for. TURNING. I have experimented with the following items and got the following results:
Tried using the FrontCol.steerAngle * Input.GetAxis("Horizontal"). This was nice but the bike flips over after just a small amount of turn. Tried using rigidbody.MoveRotation around the Z axis (forward) and get the same result.
So from my research I have gathered the following inferences:
So here is my questions:
Is there such a thing as angular momentum in Unity that I am overlooking? If so, where do I access it? If there is not angular momentum, how would I simulate this correctly in my script to always 'pull' the bike back to the straigh upright position over time when the left and right buttons are released?
Thank you greatly in advance for any insight you may provide in this matter.
I am facing little different issue with bike racing game... my bike flips after a level of speed but tuning of rotating bike is fine.... you can check this link http://forum.unity3d.com/threads/146724-Motorcycle-Physic-Move-bikes-up-from-back-side