Smooth waypoint traversing

Posted by TheBroodian on Game Development See other posts from Game Development or by TheBroodian
Published on 2012-10-02T00:43:59Z Indexed on 2012/10/02 3:57 UTC
Read the original article Hit count: 280

Filed under:
|
|
|
|

There are a dozen ways I could word this question, but to keep my thoughts in line, I'm phrasing it in line with my problem at hand.

So I'm creating a floating platform that I would like to be able to simply travel from one designated point to another, and then return back to the first, and just pass between the two in a straight line. However, just to make it a little more interesting, I want to add a few rules to the platform.

  1. I'm coding it to travel multiples of whole tile values of world data. So if the platform is not stationary, then it will travel at least one whole tile width or tile height.
  2. Within one tile length, I would like it to accelerate from a stop to a given max speed.
  3. Upon reaching one tile length's distance, I would like it to slow to a stop at given tile coordinate and then repeat the process in reverse.

enter image description here

The first two parts aren't too difficult, essentially I'm having trouble with the third part. I would like the platform to stop exactly at a tile coordinate, but being as I'm working with acceleration, it would seem easy to simply begin applying acceleration in the opposite direction to a value storing the platform's current speed once it reaches one tile's length of distance (assuming that the tile is traveling more than one tile-length, but to keep things simple, let's just assume it is)- but then the question is what would the correct value be for acceleration to increment from to produce this effect? How would I find that value?

© Game Development or respective owner

Related posts about XNA

Related posts about 2d