Problem with "move toward" in conjunction with "distance to" -
06-06-2008, 05:24 PM
In attempting to do all of the problems I'm assigning to students this summer, I encountered the following problem.
1. Add a dragon and a blimp to the world.
2. Turn the dragon to face the blimp.
3. Move the dragon toward the blimp, the distance between the dragon and blimp.
The problem occurs in step 3. If the amount to move is blimp->distance to dragon, the results are as expected. However, if the amount to move is dragon->distance to blimp, the dragon moves through and past the blimp, such that he ends up about as far away as he started (just on the opposite side of the blimp). It seems that the order in which the objects are presented to the "distance to" function affects the result.
Have I misinterpreted how "move toward" or "distance to" is supposed to work? It would be nice to be able to explain to students why this discrepancy occurs or to confirm this is a bug.
I've attached the problematic code, which includes comments about the starting and ending coordinates of the blimp and the dragon for both cases. I have not yet tested to see whether all objects behave this way, or if it is just the dragon and the blimp.
|