Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an animation of traffic. I have 20 cars in road network, each car have a starting node and end node. Each car know how much distance does it need to travel in order to reach the end node. I move cars each 20 ms for 10 px. To move all cars from their start node to end node I need 60 iterations. That is 60*20ms = 1200ms.

Now I want to convert this time, or use data that I have, to a real time where car move 50km/h. How can I do that? Any idea?

share|improve this question
up vote 4 down vote accepted

Distance between nodes / Speed = Travel time

1km / 50kmh = 0.02hours

That means that if you have 1km between your nodes the time it should take a car to drive it is 1.2minutes.

Each update then should move a car by Update step * Speed. In you case that is 1/60/60/50hours * 50 = 0,00027777 kilometers. (Note that measurement units should match) More conveniently put - each 20ms car travels 0.27meters.

share|improve this answer
@Ivansek: What Krom shows here very well is that you get to define the scale. You get to choose how many pixels are equal to 1 meter and from that you can work out the 'real world' speed equivalents. – Baggers Aug 28 '12 at 10:30

Your Answer


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.