Archived

This topic is now archived and is closed to further replies.

rotating velocity vector to match cars orientation...

This topic is 5146 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

Hi guys, I''ve got a velocity vector on a car and as the car changes direction I want the velocity vector to align to its orientation. At the minute I''ve got the following: Vx = (Vx + dt * accn) * cosf(theta) Vz = (Vz + dt * accn) * sinf(theta) Where theta is the cars orientation angle in radians. 0 being straight ahead. This works when theta is 0, and hence is going forward with velocity Vx, but when turning the velocity slows down to a crawl, and doesn''t give me enough velocity to move. Any ideas where I''m going wrong?? Cheers,

Share this post


Link to post
Share on other sites
Ugg... well, to start, your equations are a little on the strange side. You are using the full acceleration value for both coordinates, even when you are not pointing in that direction...

Basically, you might have better luck storing the magnitude of velocity, ie speed, and an angle for the direction it is pointing in. That way all you have to do is increment the speed and keep track of what direction the car is facing.

Now, if you are looking for a realistic car sim, you would make some changes. First, a car doesn''t just start going the direction it turns. Friction tries to stop it dfrom continuing on its last path but that doesn''t always happen (skid). To do this realistically you would need to implement friction, and then you wouldn''t have to turn the vector yourself.

Share this post


Link to post
Share on other sites