- Tue 5 Dec 2017, 01:50
MattLB's suggestion should do the trick. If anyone is wondering if it can be done in a more reliable way, no matter your FPS or movement speed, you can do a simple analytic test. TimeDelta() returns the time elapsed since the last frame, your object is moving at "Speed" pixels/second, and your destiny is at "Distance" pixels of distance, then if:
Your object will reach the destiny this frame, so you can put it right on the destiny an start the destiny-reached-logic. This is because Speed * TimeDelta() returns the distance your object can advanced in TimeDelta() seconds. This is other type of logic, instead moving the object this entire distance and then check if it is close to the destiny (you have problems here at low FPS or high speeds), check if the distance it can advance is less than the distance it needs to advance
I haven't tested it, pure theory, but I guess it works better if you put this check before the event your start moving, to avoid it: Set destiny, moving very fast, automatically reach the destiny in the same frame instead waiting the next frame.
I should be studying now :/