I do use animationpath.constantspeed when I begin. But what I need to know is not only the initial speed. If I want to accelerate or decelerate a car, I would like to increase or decrease the car based on not the initial speed, but the speed when last timer event triggered.
For example, the initial speed is 20mi/hr. To avoid clash, I calculate certain distance every 20 times a second. While the distance is too close, one car keep speeding up 20 percent and the other car keep slowing down 20 percent. So one car could speed up to
20 + 20*0.2 = 24mi/hr,
24 + 24*0.2 = 28.2mi/hr, (I need to know the current speed is 24)
28.2 + 28.2 *0.2 = 34.56mi/hr, (I need to know the current speed is 28.2)
and so on; and the other car could slow down to
20 - 20*0.2 = 16mi/hr,
16 - 16*0.2 = 12.8mi/hr, (I need to know the current speed is 16)
12.8 - 12.8*0.2 = 10.24mi/hr, (I need to know the current speed is 12.8)
and so on.
Sorry about the trivial details. Do you think it is feasible? Thanks a lot!
|