Example of detecting whether a target is reachable by moving in a straight line
In my recent project, since the team has quite a few junior ActionScript devs, what was supposed to be pathfinding got cut down to straight-line collision. And the tragic part is, they still tell me the straight-line collision is broken. Yesterday a guy was having the character do a per-pixel collision check after every step to decide whether it could walk. Let me repeat myself one more time: that’s both inaccurate and inefficient. Today I’m posting this example to show the recommended way to do straight-line collision: first draw a line and hit-test it against the walkable/blocked model, and only once you’ve confirmed the destination is reachable do you move the character straight there (speed control can come later, it’s unrelated to this example).