x


Motorcycle/Bike Physics Trouble

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:

  1. Once the body tilts, it will continue to tilt until it falls unless countered by some force.
  2. The real world force that causes a bike to stay upright is angular momentum.

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.

more ▼

asked Jul 11 '11 at 07:34 AM

masterjaso gravatar image

masterjaso
1 1 1 1

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Im no expert and im not sure of the exact code you would use but i would

set normal position then

whenever left or right key is not pressed return to normal position over time

good luck

more ▼

answered Jul 04 '12 at 08:53 AM

lvlegab1te gravatar image

lvlegab1te
1

(comments are locked)
10|3000 characters needed characters left

Experienced the same problem.... any replys for this prob???

more ▼

answered Apr 14 '12 at 06:25 PM

goutham gravatar image

goutham
0

(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Aug 08 '12 at 11:58 AM

PAHeartBeat gravatar image

PAHeartBeat
251 1 4 4

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2241
x69
x28
x6

asked: Jul 11 '11 at 07:34 AM

Seen: 2339 times

Last Updated: Aug 08 '12 at 11:58 AM