Jump to content
  • Advertisement
Sign in to follow this  

Car Physics - Steering

This topic is 3042 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all.

First, i would like to apologize for my bad English.

I am having troubles with the Marco monster's cars physics tutorial.

I am on the Steering at low speed part.

I cannot get the good equation and i don't understand where the problem is.

Basically, to move my car in a direction in degrees, with a speed value, i use this function :

this.car.x += speed * Math.cos((this.car.rotation) * PI / 180);
this.car.y += speed * Math.sin((this.car.rotation) * PI / 180);

This, is working great, i can move my car in any direction from 0 to 360 degrees with a speed value.

Then i try to know the angular Velocity by following the tutorial and get stuck with something.

Here is how i proceed.

First i want to get the Radius of the circle given by the wheels projection triangle.

// GET RADIUS //==============================================================================
private function getRadius(L:Number, aDelta:Number):Number {
var R:Number = L / Math.sin(aDelta);
return Math.abs(R);

so here, L is the wheel base, wich is equal to 110 pixels.
And my steering angle is 25;


var R:Number = getRadius(110, 25); // i get 831.11 pixels
var angularVelocity:Number = 2 / R;
//then angular velocity converted to degrees.
angularVelocityD = 180 * (angularVelocity) / PI;

this.car.rotation += angularVelocityD;
this.car.x += 2 * Math.cos((this.car.rotation) * PI / 180);
this.car.y += 2 * Math.sin((this.car.rotation) * PI / 180);

But, this doesn't work.
I know that the angular velocity is in Radian so because my car move with degrees i am pretty sure that i need to convert the value in degrees, but i may be wrong.

Any help would be greatly appreciated.
Thank you very much.

Share this post

Link to post
Share on other sites
I am pretty sure that Math.sin() takes an angle in radians so 25°
is no valid input for getRadius as this has to be convertet to radians.

Share this post

Link to post
Share on other sites
Hello Synacker.
Thank you for your reply.

Yes, you are right, i notice that after some time.

I think i finally make it works !
My car turn now properly at low speed.

I don't have time right now, but i will post the final code as soon as possible for people who are interested in it.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!