Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm developing simple traffic educational game like https://market.android.com/details?id=cz.allianz.krizovatky.android . When the player taps on car sprite, it started to move with other cars. If player made a mistake in choosing car, collision happens.

I decided to use Andengine for this game, because I have time limitation in developing it. So, the main problems is: How to make car automatically move along specified path with smooth turns? (and how to specify this path on map)

share|improve this question

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.