What's the best way to move cars along roads

Posted by David Thielen on Game Development See other posts from Game Development or by David Thielen
Published on 2012-12-08T00:30:37Z Indexed on 2012/12/08 6:01 UTC
Read the original article Hit count: 226

Filed under:
|
|

I am implementing car movement game (sort-of like Locomotion). So 60 times a second I have to advance the movement of each car. The problem is I have to look ahead to see if there is a slower car, stop sign, or red light ahead. And then slow down appropiately.

I also want to have the cars take time to go from stopped to full speed and again to slow down. I'm not implementing full-blown physics, but just a tick by tick speed up/slow down as that provides most of the realism to match what people expect to see.

The best I've come up with is to walk out the full distance the car would travel of it was slowing to a stop and see if anywhere along that path it needed to slow down or stop. And then move it forward appropiately.

I am moving the cars 60 times a second so I need this to be fast. And walking out that whole path each tick strikes me as processor intensive.

What's the best way to do this?

© Game Development or respective owner

Related posts about path-finding

Related posts about movement