Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Car steering algorithm?

i've already asked something similar, but now i've the problem to manage and realize a "realistic" steering for a simple 2d (top-down) car racing game.

How can i do a "realistic" steering for the car ? (i use c# but another language is welcome;)) Using Sin and Cos ? If yes, how ? Thanks in advance!

like image 550
stighy Avatar asked Oct 25 '10 17:10

stighy


People also ask

How does a car steering system work?

The system involves a circular gear (the steering pinion) which locks teeth on a bar (the rack). It also transforms big rotations of the steering wheel into small, accurate turns of the wheels, giving a solid and direct feel to the steering.

What is automatic steering control system?

Automatic steering wheel is a basic and crucial part of a driverless vehicle which is highly recognized as the finally trends of vehicle. In comparison with hydraulically power system, the electric power steering (EPS) system is a new power steering system which could provide power when the driver steers.

Is a steering wheel a control system?

A steering wheel (also called a driving wheel (UK), a hand wheel, or simply wheel) is a type of steering control in vehicles.


2 Answers

I'm on my lunch break so I can't do tremendous justice to the "best" answer, but the pseudocode looks something like this:

y_change = sin(rotation) * speed;
x_change = cos(rotation) * speed;

car.x += x_change;
car.y += y_change;

you would execute this code in every frame; rotation would be controlled by your steering input, and speed would be controlled by your acceleration input.

like image 122
Brian Driscoll Avatar answered Oct 13 '22 07:10

Brian Driscoll


You will probably want to use a physics engine that someone else has already created. I've heard good things about the XNA Physics API.

I would imagine that you will have to use sine and cosine, but that is the just the tip of a VERY large iceberg...

like image 41
Abe Miessler Avatar answered Oct 13 '22 06:10

Abe Miessler