I'm developing simple traffic educational game, like "Allianz Křižovatky". When the player taps on a car sprite, it should start to move with the other cars. If the player made a mistake in choosing a car, a collision happens.

I decided to use AndEngine for this game, because I have time limitations in developing it. How do I make the car automatically move along a specified path, with smooth turns? How would I specify this path on a map?


1 Answer 1


If you already know the path then to make it move smoothly you would apply a low-pass filter to the actual movement. A simple low-pass filter that might work for you is the weighted moving average.

For example, instead of snapping the car directly to the path like this:

car.x = pathNode.x
car.y = pathNode.y

You would only move the car partway to where the next node is:

car.x = car.x + (pathNode.x - car.x) * 0.8
car.y = car.y + (pathNode.y - car.y) * 0.8

This gives up some accuracy to smooth out sharp turns over time. You will have to play around with the weight (0.8 in this case) until it looks good.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .