Assume you have an array or list of platforms. If so, then compute the distance from your `finalposition` variable to each of the platforms, and choose the closest one. Then set `finalposition` to that platform position.
↧